.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
 

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

Similar Threads

DateTIme help 2
date time formatting 3
String to DateTime 1
DateTime and localization 2
convert date 1
DateTime sql server - sqldataadapter 2
datetime format 3
DateTime field on DataGrid 2

Back
Top