PC Review


Reply
Thread Tools Rate Thread

Date Time Culture Format

 
 
Brad
Guest
Posts: n/a
 
      10th Jan 2007
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
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      10th Jan 2007
Brad <(E-Mail Removed)> 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?


CultureInfo.CurrentCulture.DateTimeFormat will give you a
DateTimeFormatInfo which should have the info you need.

In some situations, CurrentUICulture would be more appropriate. See the
docs for more details.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Mihai N.
Guest
Posts: n/a
 
      11th Jan 2007
Jon Skeet [C# MVP] <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> Brad <(E-Mail Removed)> 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?

>
> CultureInfo.CurrentCulture.DateTimeFormat will give you a
> DateTimeFormatInfo which should have the info you need.
>
> In some situations, CurrentUICulture would be more appropriate. See the
> docs for more details.

Sorry to contradict, but in all situations dealing with formats
(number/date/time), CurrentCulture is the thing you need.
See "Two things that suck about CurrentUICulture"
http://blogs.msdn.com/michkap/archiv...0/1442340.aspx



--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      11th Jan 2007
Mihai N. wrote:
> Jon Skeet [C# MVP] <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>
> > Brad <(E-Mail Removed)> 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?

> >
> > CultureInfo.CurrentCulture.DateTimeFormat will give you a
> > DateTimeFormatInfo which should have the info you need.
> >
> > In some situations, CurrentUICulture would be more appropriate. See the
> > docs for more details.

> Sorry to contradict, but in all situations dealing with formats
> (number/date/time), CurrentCulture is the thing you need.
> See "Two things that suck about CurrentUICulture"
> http://blogs.msdn.com/michkap/archiv...0/1442340.aspx


Ah, I see. I was under the mistaken impression that in an ASP.NET
setting, the CurrentUICulture would be set to the CultureInfo of the
browsing user whereas CurrentCulture would be the system default
culture.

It is indeed a bit of a mess. Still, just one more bit of i18n
trickery...

Jon

 
Reply With Quote
 
Mihai N.
Guest
Posts: n/a
 
      12th Jan 2007
> It is indeed a bit of a mess. Still, just one more bit of i18n
> trickery...

Well, each area with its own trickery :-)


--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting text format of time/date into Excel time/date for subtr YY san. Microsoft Excel Worksheet Functions 5 25th Feb 2010 07:13 AM
Convert date + time text format to date format =?Utf-8?B?UGF1bCBIbw==?= Microsoft Excel Worksheet Functions 2 22nd May 2007 05:47 PM
Convert a latebinded DataTable column's format from DateTime to string (or format the date time value) RSH Microsoft VB .NET 0 6th Dec 2006 03:49 PM
Converting Date Time format to Month YEar format Prashant Sisodia Microsoft Excel Worksheet Functions 1 11th Jun 2004 03:56 PM
Re: Javascript: date in culture/language format. Vidar Petursson Microsoft ASP .NET 0 15th Aug 2003 11:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:45 AM.