Click to See Complete Forum and Search --> : convert DateTime from one TimeZone to another


musaler
May 7th, 2006, 12:47 AM
Hello all!

I have Date "2/1/2005 10:30:00" in TimeZone with UTC offset -5(this is NOT my local timezone)
How can I convert this time to any other timezone with different UTC offset in C# taking account Dayligh savings?

As I understood from MSDN there are 2 functions in DateTime class ToUniversalTime() and ToLocalTime(), but there is no function wich transferes from one timezone to another.

Help please

Thank you

stepi
May 7th, 2006, 01:06 PM
Hi,
See this http://radio.weblogs.com/0126569/2004/09/01.html

aniskhan
May 7th, 2006, 10:37 PM
u can use toLocalTime and toUniversalTime to convert from local toUTC and from UTC to local times; somethg like this
DateTime dtUTC=dtLocal.toUniversalTime();

DanielaTm
May 8th, 2006, 03:01 AM
You also can use Culture:

public static double mymethod(CultureInfo culture, object DateDebut)
{
if (culture == null)
culture = CultureInfo.CurrentCulture;
DateTime dateStart = Convert.ToDateTime(DateDebut, culture); ;
// some code
}

I use it in all my applications. I convert datetime function of culture, and if no culture specified, it takes the current culture of the client's computer

Hope it helped