Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

Currently i'm using Win10, where at the bottom the date is displaying as gregorian date,
but when i'm using DateTime.Now() is getting Hijri Date.

What I have tried:

Label1.Text = DateTime.Now.ToString();

Output:
06/11/37 09:46:04 ص


I want Grigorian DateTime here as default.

Can anyone please help me.

Thanks
Posted
Updated 8-Aug-16 21:05pm

1 solution

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.

C#
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.
 
Share this answer
 
Comments
abdul subhan mohammed 9-Aug-16 3:13am    
The problem is only in my machine, if i use DateTime.now(), is working fine in other machines. so, instead of doing in coding, i want to do it, in my machine setting.
Richard MacCutchan 9-Aug-16 4:05am    
Go to Control Panel -> TIME & LANGUAGE -> Region & Language -> Additional date, time & regional settings.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900