Format date to system timezone
-
Hi, I have DateTime objects that are all GMT+0 times. I'd like to display them in my program so that it matches system's timezone. For instance, the DateTime "2009-03-14 16:00:00" would be ouput as a string as "2009-03-14 17:00:00 (GMT+1)" if my system timezone is set to GMT+1. How can I do this? DateTime.ToString MSDN doc doesn't help; I'm not sure if there's an easy way to do this :/
-
Hi, I have DateTime objects that are all GMT+0 times. I'd like to display them in my program so that it matches system's timezone. For instance, the DateTime "2009-03-14 16:00:00" would be ouput as a string as "2009-03-14 17:00:00 (GMT+1)" if my system timezone is set to GMT+1. How can I do this? DateTime.ToString MSDN doc doesn't help; I'm not sure if there's an easy way to do this :/
You need to use the locale classes to work out what the timezone is, then build your own string that shows this information. http://msdn.microsoft.com/en-us/library/system.datetimeoffset.aspx[^] is one option, the other is to convert the time to UTC, and then work out the difference.
Christian Graus Driven to the arms of OSX by Vista.