How can I get DateTime.Now
in Gregorian calender when client calendar is non-Gregorian?
My project is a Silverlight with C# code and client default calender is not predicted.
MM/DD/YYYY - American style Gregorian date format. DD/MM/YYYY - European style Gregorian date format.
Gregorian date. This format of date corresponds to any of the industry or IBM standard date formats supported by DB2. For example, the International Organization for Standardization (ISO) format is CCYY-MM-DD. 2013-12-14 is equivalent to the calendar date December 14 th 2013.
The Gregorian calendar, like the Julian calendar, is a solar calendar with 12 months of 28–31 days each. The year in both calendars consists of 365 days, with a leap day being added to February in the leap years. The months and length of months in the Gregorian calendar are the same as for the Julian calendar.
A DateTime value has no format. Internally it's just a count of ticks since the epoch, 0001-01-01 00:00 in .NET. Formatting is when you call ToString.
Just use a different CultureInfo for the culture that has the calendar you want, e.g.
CultureInfo french = CultureInfo.GetCultureInfo("fr-FR");
String nowStr = DateTime.Now.ToString( french );
Use CultreInfo.InvariantCulture
if you just to use a predictable Western culture with a Gregorian calendar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With