Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I tried using UTC time and Datetime time but I get zero:

VB
UTChour = DateTime.UtcNow.ToString("HH")
Localhour = DateTime.Now.ToString("HH"))
TimeZone = Localhour - UTChour
If TimeZone <= 13 Then TimeZone = TimeZone - 24


I also get zero if I try this statement:

C#
TimeZone2 = = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time")).ToString("HH")
Posted
Updated 11-Feb-14 3:44am
v2
Comments
Sergey Alexandrovich Kryukov 11-Feb-14 12:07pm    
Why finding the time zone?!
—SA

1 solution

Why not use TimeZone.CurrentTimeZone[^]?
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 11-Feb-14 12:07pm    
Of course, why not? :-) — a 5.
—SA
Maarten Kools 11-Feb-14 12:31pm    
Heh, thanks!

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