use DateTime format error

G

Grey

I use the DateTime format to change the date format, i.e.
string a = "21/02/2004";
Convert.ToDateTime(a).ToString("MMMM dd, yyyy");
These two lines work well in my VS.NET development machine. But it fail in
my production server. I don't know the reason??
My development machine: winXP Pro, VS.NET 2003
My Production machine: Win2000 server with SP4, .NET Framework 1.1
 
H

Hans Kesting

Grey said:
I use the DateTime format to change the date format, i.e.
string a = "21/02/2004";
Convert.ToDateTime(a).ToString("MMMM dd, yyyy");
These two lines work well in my VS.NET development machine. But it fail in
my production server. I don't know the reason??
My development machine: winXP Pro, VS.NET 2003
My Production machine: Win2000 server with SP4, .NET Framework 1.1

The settings on your development machine specify a default dd/MM/yyyy
format,
and your server has MM/dd/yyyy.
You can specify the format with:

DateTimeFormatInfo myDTFI = new DateTimeFormatInfo();
myDTFI.ShortDatePattern = "dd/MM/yyyy";
DateTime dt = DateTime.Parse(myDateString, myDTFI);

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top