Solved

convert datetime from one timezone to another timezone

Posted on 2011-09-25
9
330 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now