OS DateTime Format Setting

B

Brad

Is there a way to determine the OS's date/time culture format (e.g.
mm/dd/yyy vs. dd/mm/yyy) setting at run time?

TIA

Brad
 
M

Mattias Sjögren

Is there a way to determine the OS's date/time culture format (e.g.
mm/dd/yyy vs. dd/mm/yyy) setting at run time?

Try checking
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDateFormat


Mattias
 
R

Rad [Visual C# MVP]

Is there a way to determine the OS's date/time culture format (e.g.
mm/dd/yyy vs. dd/mm/yyy) setting at run time?

TIA

Brad

Hey Brad,

Here is a small application that shows you what you do. Basically the
DateTimeFormatInfo class is your best friend. Check out MSDN for the full
list of properties it offers. But here are the basics:

//
// Get the datetime format information of the current thread.
// This defaults to the operating system settings
//
System.Globalization.DateTimeFormatInfo dfi =
Thread.CurrentThread.CurrentCulture.DateTimeFormat;
//
// Get the short date pattern
//
Console.WriteLine(dfi.ShortDatePattern);
//
// Get the long date pattern
//
Console.WriteLine(dfi.LongDatePattern);
 

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

Top