473,396 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Date Time Culture Format

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
Jan 10 '07 #1
4 2799
Brad <br************@roche.comwrote:
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 - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 10 '07 #2
Jon Skeet [C# MVP] <sk***@pobox.comwrote in
news:MP************************@msnews.microsoft.c om:
Brad <br************@roche.comwrote:
>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
Jan 11 '07 #3
Mihai N. wrote:
Jon Skeet [C# MVP] <sk***@pobox.comwrote in
news:MP************************@msnews.microsoft.c om:
Brad <br************@roche.comwrote:
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

Jan 11 '07 #4
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
Jan 12 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Chris | last post by:
Hi, how do I validate a date using a RegularExpression-validator control ? e.g. 05/20/2004 (May 20, 2004) Or should I use another validator-control ? and how ? Thanks
1
by: Neo | last post by:
I use CompareValidator to validate a date. But CompareValidator can only one date format at one time. if the dateorder is "mdy", date format can only be mdy even if date format is ymd. But users...
7
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
50
by: z. f. | last post by:
HI, i have string in format dd/mm/yyyyy hh:mm:ss and giving this as an input to DateTime.Parse gives a string was not recognized as a valid date time format string error. how do i make the parse...
15
by: JenHu | last post by:
Hi expert, I have a data field (birthdate) contains a datetime datatype (mm/dd/yyyy), how can I convert to mmdd?? say, the birthday is 8/1/1979 and convert to mmdd DOB =...
50
by: Doug | last post by:
I can't imagine this is that hard but I'm sure having a struggle finding it. How do I convert a value like "111403" do a DateTime variable in DotNet (i.e. 11/14/2003)?
14
by: eric.goforth | last post by:
Hello, I'm trying to convert a string to a date time in a C# web service. I'm passing in a string parameter and I have a localization setting in my Web.config file: My app is blowing up on...
20
by: andreas | last post by:
When I copy a vb.net project using date formats from one PC with a windows date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I get errors. How can I change for a while in the...
1
by: Tom | last post by:
I need to modify the default behavior of Date.ToString() on all pages of my ASP.Net (2.0) site. I don't need to localize my app (it's an intranet-only site), but I need to enforce a specific...
21
by: Darin | last post by:
I have an applicatoin that works 100% perfect when running on a machine setup for English (United States), but when I change it to Spanish (Mexico), the dates start giving me fits. THe reason is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.