.NET and DateTime

  • Thread starter Thread starter Leszek Taratuta
  • Start date Start date
L

Leszek Taratuta

Hello,

I have a new installation of the .NET framework on Win 2003 Srv. I need to
use the Convert.ToDateTime(str) method. The problem is it always converts
the provided string to American format MM/dd/yyyy. I need the method to
convert strings to another format: dd-MM-yyyy.
Is there any global configuration setting for .NET, so I could provide the
default date format? It ignores setting in "Control Panel". I emphasize that
I do not want to use any additional methods such as DateTime.ParseExact() to
achieve this. I would like to set the format once and globally for all .NET
applications.

Thanks,
Leszek Taratuta
 
Leszek Taratuta said:
I have a new installation of the .NET framework on Win 2003 Srv. I need to
use the Convert.ToDateTime(str) method. The problem is it always converts
the provided string to American format MM/dd/yyyy. I need the method to
convert strings to another format: dd-MM-yyyy.
Is there any global configuration setting for .NET, so I could provide the
default date format? It ignores setting in "Control Panel". I emphasize that
I do not want to use any additional methods such as DateTime.ParseExact() to
achieve this. I would like to set the format once and globally for all .NET
applications.

I suspect you *could* set the current culture's DateTime default format
string, but the best way to work (IMO) is to always specify the format
you want, eg

string date = DateTime.Now.ToString ("dd-MM-yyyy");
 
Hi Leszek,

In addition to Jon, you can see what this can do for you, however I have the
same idea in this as Jon (and that I write not often)

Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")

In the culture you want of course.

Cor
 
Thank you very much.
Where is the best place to put this code? Global.asax?

Thanks,
Leszek
 
Back
Top