umeshchaand

New Member
Joined
Jun 23, 2011
Messages
2
I get a date time exception while calculating time difference between two dates in C# code.

This occours only with 32 bit Windows 7.

Could anyone help me with this ..


return printDate.ToString("MM/dd/yyyy HH:mm:ss");
 

Solution
This works fine on my 32 and 64-bit Windows 7:

using System;


public class TimeTest
{
public static void Test()
{
DateTime time = DateTime.Now;
string format = "MM/dd/yyyy HH:mm:ss";
Console.WriteLine(time.ToString(format));
}
}

Josephur

Windows Forum Admin
Staff member
Premium Supporter
Microsoft Certified Professional
Joined
Aug 3, 2010
Messages
1,289
This works fine on my 32 and 64-bit Windows 7:

using System;


public class TimeTest
{
public static void Test()
{
DateTime time = DateTime.Now;
string format = "MM/dd/yyyy HH:mm:ss";
Console.WriteLine(time.ToString(format));
}
}
 

Solution

Elmer

Extraordinary Member
Joined
Mar 5, 2010
Messages
3,864
This works fine on my 32 and 64-bit Windows 7:

using System;


public class TimeTest
{
public static void Test()
{
DateTime time = DateTime.Now;
string format = "MM/dd/yyyy HH:mm:ss";
Console.WriteLine(time.ToString(format));
}
}
Hey Josephur, would that work in the UK but as dd/MM/yyyy HH:mm:ss, as we write the day first (smallest to largest, d,m,y!:))
 

Josephur

Windows Forum Admin
Staff member
Premium Supporter
Microsoft Certified Professional
Joined
Aug 3, 2010
Messages
1,289
He is trying to format it specifically it seems, however you can change the format however you would like or let the system choose.