Advertisement

09.07.2007 at 07:06PM PDT, ID: 22814755
[x]
Attachment Details

DateTime question in C#

Asked by tooki in Microsoft Visual C#.Net, .Net Editors & IDEs, Visual Studio .NET 2005

Tags: datetime, time, utc

I am writing this piece of code in a C# application in MS Visual studio. I want to use GMT (or UTC) time throught in the application. I do not want to use the local time to show up anywhere in the application page.

Here are my code -- it does not compile:
 
DateTime date1 = Convert.ToDateTime(runDate);
string newTime = date1.ToString("yyyy-MM-dd' 'HH:mm:ss");
dr["LastUsedDate"] = Convert.ToDateTime(newTime);

I can compile the code but when I execute, I get error on the last line (3rd line) in the above code -- it says that the argument to ToDateTime -- that is newTime is not in correct format.

How can I fix this?

-tooki
Start Free Trial
[+][-]09.07.2007 at 07:50PM PDT, ID: 19852137

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.07.2007 at 07:55PM PDT, ID: 19852152

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.07.2007 at 08:07PM PDT, ID: 19852192

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.07.2007 at 08:23PM PDT, ID: 19852235

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C#.Net, .Net Editors & IDEs, Visual Studio .NET 2005
Tags: datetime, time, utc
Sign Up Now!
Solution Provided By: drichards
Participating Experts: 2
Solution Grade: A
 
 
[+][-]09.07.2007 at 08:35PM PDT, ID: 19852256

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628