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.
Answer: 1
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.
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog