C# .NET - how to convert the Universal time into local time using c#.net
Asked By paramesh pk on 27-Aug-09 03:02 AM
Hi Friends,
Good Day. I Need ur help!. for example. am registering login page in Other Country called USA. but the server is in india. while saving it has to calculate the Usa date and the current date of india. how to calculate the universal date with current date using c# code. Reply me. Thanks.
how to convert the Universal time into local time using c#
mv ark replied to paramesh pk on 27-Aug-09 03:18 AM
UTC, or Coordinated Universal Time, is the standard international time that all time zones are expressed as offsets of. UTC does not get adjusted for daylight savings. To compute local time from UTC, simply add the time zone offset and then add an additional hour if daylight savings time is in effect.
To get the Current Time in UTC, try this -
DateTime currentTime = DateTime.UtcNow;
The DateTime.ToLocalTime method converts a DateTime value from UTC to local time. To convert the time in any designated time zone to local time, use the TimeZoneInfo.ConvertTime method.
Check these links for more info & code samples -
http://msdn.microsoft.com/en-us/library/system.datetime.tolocaltime.aspx
http://aspnet.4guysfromrolla.com/articles/081507-1.aspx