[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

convert time from MST to UTC using C#

Posted on 2009-12-16
8
Medium Priority
?
932 Views
Last Modified: 2013-12-17
I have tim in "2009-11-24 01:15:00" MST i want to convert it to UTC,
Can you please help how to do this using C#.

thanks
0
Comment
Question by:ram27
8 Comments
 
LVL 7

Expert Comment

by:technofile
ID: 26066215
do a Cdate(yourtimestring).Addhours(7)
0
 
LVL 7

Expert Comment

by:technofile
ID: 26066227
Im sorry just do a Cdate(yourtimestring).ToUniversalTime
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
LVL 17

Expert Comment

by:CSecurity
ID: 26066246
Yes, in link I gave you, you'll see ToUniversalTime examples in C# and VB.NET, just follow the instructions on the page.
0
 

Author Comment

by:ram27
ID: 26066249
Also my time zone is (GMT -7) Arizona, it never follow day light saving time.
I mean time in AZ never changes( even in Mountain time some areas follow day light saving).

0
 
LVL 7

Expert Comment

by:technofile
ID: 26066260
Or if you have a datetime object just do a yourdatetime.ToUniversalTime that handles all that daylight savings stuff as well
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 26066270
Technofile's on the right track, except CDate is a VB function, no such thing in C#. ;)

If you have the string "2009-11-24 01:15:00" then you need to convert it to a DateTime object, using DateTime.Parse, then call .ToUniversalTime() on that DateTime object:
DateTime utc = DateTime.Parse("2009-11-24 01:15:00").ToUniversalTime();


If you already have a DateTime object, all you need is to call .ToUniversalTime():
DateTime utc = myDateTimeObject.ToUniversalTime();
0
 
LVL 17

Accepted Solution

by:
CSecurity earned 2000 total points
ID: 26066430
Just follow examples on link I gave you at first
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month17 days, 22 hours left to enroll

830 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