Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
3.40/5 (2 votes)
See more:
Hi,
i am trying to convert a particular time to utc and saving the utc time into the database,its works fine if i run the code on local machine,if i move the same code to dev server,its failed to convert to utc,can anybody tell me how to fix it

What I have tried:

C#
static TimeZoneInfo UTCZone = TimeZoneInfo.FindSystemTimeZoneById("UTC");
TimeZoneInfo.ConvertTime(Mytime,UTCZone);

this is how i am trying to convert,
Posted
Updated 8-Nov-17 0:15am
v4
Comments
Peter_in_2780 8-Nov-17 5:26am    
I'd guess that your local machine is running on local time, and the server is (very sensibly) running on UTC.
Member 13509784 9-Nov-17 0:36am    
thank you peter_in i fixed the issue.thanks for your support
Sinisa Hajnal 9-Nov-17 5:46am    
Close the question if it is answered. Thank you
GKP1992 8-Nov-17 5:28am    
How does it fail? Does it insert wrong values in DB or doesn't convert at all?
Member 13509784 8-Nov-17 5:37am    
inserts the record into db without converting it to utc

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