Solved

convert datetime from one timezone to another timezone

Posted on 2011-09-25
9
340 Views
Last Modified: 2012-05-12
I have a datetime for example 09-25-2011 01:00am CET. How do I convert this time to another timezone for example EST or GMT. Thanks.
0
Comment
Question by:sandya_116
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 5

Expert Comment

by:speak2ab
ID: 36596253
I usually use this site for converting time in different zones. http://www.timeanddate.com/worldclock/converter.html 

This should put you on the right direction. For basic programming purpose you might want to use the GMT as a reference point for other time conversions. GL
0
 

Author Comment

by:sandya_116
ID: 36596257
I am looking for asp.net code to do this.
0
 

Author Comment

by:sandya_116
ID: 36596266
The format on the start date time is flexible. But, it has a time and timezone for the start date. I need to convert this to the server's time zone datetime or another time zone.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:speak2ab
ID: 36596275
Now i see what you mean. I guess it will be clearer if you had included that in your question.

Have a look at this blog posts:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=593

and

http://r4r.co.in/asp.net/01/tutorial/asp.net/Convert%20Time%20in%20Different%20TimeZones%20in%20ASP.NET%20using%20C-sharp.shtml
0
 
LVL 5

Expert Comment

by:speak2ab
ID: 36596283
For a step by step explanation of the steps read Scott's article
http://www.4guysfromrolla.com/articles/081507-1.aspx#postadlink
0
 

Author Comment

by:sandya_116
ID: 36596289
the zone asp.net is specified in the questions so I think everyone understands it. oh well, I already looked at these articles and didn't help me. The problem I have is I get this datetime with a timezone so that cannot be changed. I need to convert this to server timezone.
0
 
LVL 12

Accepted Solution

by:
rajapandian_81 earned 500 total points
ID: 36597282
Hi,

Try below code:

DateTime DT = DateTime.ParseExact("09-25-2011 01:00am CET", "MM-dd-yyyy hh:mmtt CET", null);
TimeZoneInfo sourceTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time");
TimeZoneInfo DestTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
DateTime DT_EST = TimeZoneInfo.ConvertTime(DT, sourceTimeZone, DestTimeZone);

Open in new window

0
 

Author Comment

by:sandya_116
ID: 36598582
Thanks rajapandian_81. That is working but just a quick question can it consider daylight saving time as well?
0
 
LVL 12

Expert Comment

by:rajapandian_81
ID: 36707619
It should consider daylight saving time.

To know the properties and methods:
http://msdn.microsoft.com/en-us/library/bb396389.aspx
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question