Solved

how can I convert System.DateTime.Now to UTC time?

Posted on 2008-06-25
2
915 Views
Last Modified: 2013-11-26
Hi,
I am using c# in Visual Studio 2005

I have the followin object:
System.DateTime currentTime = new DateTime.Now

I need for currentTime variable to be UTC time. How can I do this?

Thanks
0
Comment
Question by:vielkacarolina1239
2 Comments
 
LVL 16

Accepted Solution

by:
CuteBug earned 400 total points
ID: 21866153
Use DateTime.UtcNow
0
 
LVL 10

Assisted Solution

by:joriszwaenepoel
joriszwaenepoel earned 100 total points
ID: 21866352
DateTime.UtcNow is correct for the current time.

If you need to convert other datetimes as well, then you can use ".ToUniversalTime" to ceonvert an existing (local) datetime to UTC.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

895 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

12 Experts available now in Live!

Get 1:1 Help Now