PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms OS DateTime Format Setting

Reply

OS DateTime Format Setting

 
Thread Tools Rate Thread
Old 10-01-2007, 06:59 PM   #1
Brad
Guest
 
Posts: n/a
Default OS DateTime Format Setting


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


  Reply With Quote
Old 10-01-2007, 08:51 PM   #2
Mattias Sjögren
Guest
 
Posts: n/a
Default Re: OS DateTime Format Setting


>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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
  Reply With Quote
Old 10-01-2007, 08:51 PM   #3
Rad [Visual C# MVP]
Guest
 
Posts: n/a
Default Re: OS DateTime Format Setting

On Wed, 10 Jan 2007 13:59:11 -0500, Brad wrote:

> 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);
--
Bits.Bytes
http://bytes.thinkersroom.com
  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off