문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top