14/02/2008

C# - Get Regional Date Settings

Heck, I don't know if this works in all circumstances so please let me know if you use this and are or are not happy with it.

string RegionalFormat = (new DateTime(2008, 2, 29)).ToString().Split("/".ToCharArray())[0] == "29" ? "d/M/yyyy" : "M/d/yyyy";


Over and Out

2 comments:

David said...

If regional format is yyyy-mm-dd will it work ?

Matt Stark said...

ya - but you'd have to change the split routine!! ... it will be splitting on "-" ... etc...