Click here to Skip to main content
15,915,082 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am newbie in c#, I write a simple console app to show current time.

C#
System.Console.WriteLine(DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss zzz"))


Why the specific format "zzz" always return -07:00 (my expected result is -08)

My computer (window server 2008) timezone is : UTC-08:00 Pacific Time (US & Canada)

Please help me :(
Posted
Comments
Sergey Alexandrovich Kryukov 13-Aug-12 0:08am    
First thing which comes to my mind is that it takes into account that stupid summer saving time...
--SA

See this link for the current UTC time:
http://www.worldtimeserver.com/current_time_in_UTC.aspx[^]
Your current timezone is PDT time as explained below:
http://www.timeanddate.com/library/abbreviations/timezones/na/pdt.html[^]
So, the output of the ToString method is correct.
 
Share this answer
 
Console.WriteLine(DateTime.Now.ToShortDateString());
 
Share this answer
 
If you change the time zone, you must restart your computer to take effect.
 
Share this answer
 
Use Console.WriteLine(DateTime.Now.Hour); or Console.WriteLine(DateTime.Now.ToShortTimeString());
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 13-Aug-12 0:07am    
Not even close.
--SA

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