Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to convert one  time zone to another with 24 hour format without using the AM and PM . Use only the Timespan.

Posted on 2012-03-19
3
Medium Priority
?
414 Views
Last Modified: 2012-03-20
TimeSpan.TryParse(datewise + ":" + "00", out _timeOfDay);
                var asd = _dt.ToString().Split(new string[] { " " }, StringSplitOptions.None);
                var _newdatetime = asd[0] + " " + _timeOfDay;
                DateTime oldTime = Convert.ToDateTime(_newdatetime);
                TimeZoneInfo timeZone1 = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
                TimeZoneInfo timeZone2 = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneInfo.Local.Id);
                DateTime newTime = TimeZoneInfo.ConvertTime(oldTime, timeZone1, timeZone2);
                DateTime new_Time = TimeZoneInfo.ConvertTimeFromUtc(oldTime, timeZone2);
                TimeSpan timeOfDay = new TimeSpan();
                TimeSpan.TryParse(newTime.ToString(), out  timeOfDay);

                new DateTime(newTime.Ticks).ToString("H tt");
                new DateTime(new_Time.Ticks).ToString("H tt");
0
Comment
Question by:searchsanjaysharma
[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
3 Comments
 
LVL 80

Expert Comment

by:arnold
ID: 37739205
You should first convert the date, time to unix time in seconds adjusting for time son to GMT, Utc time. You can then convert back in a much simpler, straight forward way way.
http://forums.devshed.com/net-development-87/unix-time-in-c-123865.html
Storing date time in at least GMT, Utc time zone makes transition simpler requiring adjustments by the time zone only. Storing using unix time stamp make the conversion a mathematical function of adding or subtracting the tz value.
0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 2000 total points
ID: 37739243
here is a nice msdn article on timezone conversions, please go through:-
http://msdn.microsoft.com/en-us/library/bb397769.aspx

here is another one, which you might find helpful:-
http://www.xiirus.net/articles/article-_net-convert-datetime-from-one-timezone-to-another-7e44y.aspx
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 37745827
ok
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

597 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