Posted 29 February 2024, 8:29 pm EST
Hello,
The incorrect day is due to the ‘new Date()’. When converting the Thai date string into a date object, it retrieves the day of the corresponding year date (2567).
The wijmo.Globalize.formatDate method converted the date object into valid date string formats (as per .NET-style Date format string). On checking your shared code snippet of .NET, it doesn’t give the day value when formatting with ‘dddd’ like ‘en-US’ culture. Can you please check it again and let us know if there is anything I missed? Below is the code snippet I used to verify the behavior.
using System;
using System.Globalization;
public class HelloWorld
{
public static void Main(string[] args)
{
DateTime aDate = new DateTime(2024, 3, 17);
string strEn = aDate.ToString("yyyy MMMM dd dddd",
CultureInfo.CreateSpecificCulture("en-US"));
string strTh = aDate.ToString("yyyy MMMM dd dddd",
CultureInfo.CreateSpecificCulture("th-TH"));
Console.WriteLine (strEn);
Console.WriteLine (strTh);
}
}
//Output
2024 March 17 Sunday
2567 17
In case you want to get the day, date, month, and year values as per the Thai calendar then you can write a custom function to get all the converted values. Please refer to the sample link below for the same:
https://jsfiddle.net/q4tLho2g/
Regards