473,796 Members | 2,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2827
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.Cur rentCulture.Dat eTimeFormat will give you a
DateTimeFormatI nfo which should have the info you need.

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

--
Jon Skeet - <sk***@pobox.co m>
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.co mwrote in
news:MP******** *************** *@msnews.micros oft.com:
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.Cur rentCulture.Dat eTimeFormat will give you a
DateTimeFormatI nfo which should have the info you need.

In some situations, CurrentUICultur e 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 CurrentUICultur e"
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.co mwrote in
news:MP******** *************** *@msnews.micros oft.com:
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.Cur rentCulture.Dat eTimeFormat will give you a
DateTimeFormatI nfo which should have the info you need.

In some situations, CurrentUICultur e 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 CurrentUICultur e"
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 CurrentUICultur e 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
1475
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
2681
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 of a web application may be around the world and since database can accept many date format, so are there any ways to let CompareValidator accept many data formats at one time? Thanks
7
31846
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 current date. If not, I'd like to display the error message to ValidationSummary. It seems to make sense to me to use CompareValidator but the problem is put the current date into CompareValidator. So, I created a hidden text field in my aspx. ...
50
4961
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 method to accept formating that i need. if i do console.writeLine DateTime.Now.ToString it gives the format: YYYY-MM-DD HH:MM:SS TIA, Z.
15
9077
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 = DS.Tables("AcctInfoTble").Rows(3)("BRTHDATE") strResult.Insert(12, DOB.PadLeft(37, " ")) ---------------------------------------------------------------------------------------------------
50
4011
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
3404
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 the first line here, with a"Value does not fall within the expected range" error.
20
35638
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 project the date format in vb.code ( not in Windows) and how can I find out which date format the PC Windows is using. Thanks for any response
1
1513
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 date/time format sitewide ("MM/dd/yyyy HH:mm:ss") and I don't want to have to write that each time I have to format a date to string. I googled CurrentCulture and Date Format, and I found some articles on customizing the default culture of your...
21
3389
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 USA is mm/dd/yyyy and mexico is dd/mm/yyyy. So, with the computer set to mexico, any standard CDATE function is going to return the date in the dd/mm/yyyy setting since that is what the computer is set to. I want to be able to enter a date in...
0
9528
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10456
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10012
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7548
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.