Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateTime.ToString() - Can you set a default? 1

Status
Not open for further replies.

MattWoberts

Programmer
Oct 12, 2001
156
GB
Hi.

I always want my dates to be in the format of "dd-MMM-yyyy". Can I set a default format for "toString" in my DateTime objects, rather than doing dtmDate.ToString("dd-MMM-yyyy") all over the code?

The only solution I can think is to create my own DateTime, and inherit from DataTime, and add my own ToString overload... there must be an easier way!!!

 
The default formatting uses the CultureInfo.CurrentCulture that is attached to your thread/process. You can change this (you need the correct security permission) by assigning a new CultureInfo object to your CurrentThread.CurrentCulture property.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top