Solved

convert datetime from one timezone to another timezone

Posted on 2011-09-25
9
336 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
  • 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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