This project is read-only.

How to convert the given time based on TimeZone?

Topics: Developer Forum
Sep 24, 2008 at 5:22 AM
Hi Guys,

I am using Olson TimeZone, and I would like to convert the give datetime based on the TimeZone.

For example:

TimeZone: Australia/Perth:
Given Time: Wednesday, September 24, 2008 12:00:00PM

Process... is to convert the Given Time based on the new TimeZone which is "Australia/Adelaide"

Result Should be:

TimeZone: Australia/Adelaide
Converted Time: Wednesday, September 24, 2008 1:00:00PM

I am having difficulty doing this process in PublicDomain. Can you share me some of your thougths on how to do this?


Nov 5, 2008 at 10:58 AM
This should do what you want:

            TzTimeZone perth = TzTimeZone.GetTimeZone("Australia/Perth");
            TzTimeZone adelaide = TzTimeZone.GetTimeZone("Australia/Adelaide");
            DateTime utc = perth.ToUniversalTime(DateTime.Parse("24-Sep-2008 12:00"));
            DateTime inAdelaide = adelaide.ToLocalTime(utc);

There's more info on the CodeProject article: