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
394 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 78

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 500 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

705 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