473,394 Members | 1,663 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,394 software developers and data experts.

datetime culture problems

Hi,

I am having difficulty with the date time parse method:

try{
System.IFormatProvider format = new CultureInfo("en-
GB", true);
DateTime dateActive = DateTime.Parse
(txtDate.Text,format);
}
catch{
throw new Exception("Unable to recognise date/time
values: use format 'dd/MM/yyyy hh:mm'");
}

It works ok on some machines but not others as it
interchanges UK for US style dates, so 14/07/03 for
fourteenth of July is misterpreted as fourteenth month
and 3/7/03 as 7th March. Why is this when I have
specified an 'en-GB' cultureInfo?

I have checked the date format settings in the Regional
and Language Options of control panel and they are ok.

Adam
Nov 13 '05 #1
1 7508
Hi
System.IFormatProvider format = new CultureInfo("en-GB", true);


if you expect the same format, independent from user any settings, try:
new CultureInfo("en-GB", false );

[ useUserOverride = false ]

--
Thomas Scheidegger - MVP .NET - 'NETMaster'
http://www.cetus-links.org/oo_dotnet.html - http://dnetmaster.net/
Nov 13 '05 #2

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

Similar topics

2
by: Iwan Petrow | last post by:
Hi, I have a column DateTime in a table in MS SQL Server database. I take this column using a Web Service and show it in a TextBox in a Web Application. I want the format of the date to be...
10
by: Kim Hellan | last post by:
I have a simple string in the format "DD-MM-YY hh:mm:ss", that I need to convert to a DateTime value. I know this is a standard problem, but please don't just link to all the MSDN pages regarding...
1
by: Doug Swanson | last post by:
I'm trying to get a datetime value (10/24/2001 6:00 AM) to display as 10/24/01 6:00. I know I could hard code some format but I'm trying to use the culture info etc. so that (and this is my...
26
by: Reny J Joseph Thuthikattu | last post by:
Hi, I have a variabe in the format of 'DD-MON-YYYY HH:MI AM' .I want to add a miniute to it.How can i do that? by manipulation i want to make '01-JUNE-2004 11:59 PM' to '02-JUNE-2004 12:00 AM'...
11
by: Cor Ligthert | last post by:
Hello everybody, Jay and Herfried are telling me every time when I use CDate that using the datetime.parseexact is always the best way to do String to datetime conversions. They don't tell why...
10
by: Philip Wagenaar | last post by:
I have some code to convert a date to the unixdatetime representation (number of seconds since 1970). Only problem is that it only counts from the whole day, it ignores the times part. So convert...
9
by: Simon Harvey | last post by:
Hi all, I'm having a bit of a problem working with dates. My computer is british, but I'm developing an american application so I therefore need to use american dates. But I can't get my...
0
by: H5N1 | last post by:
Hi there I know that a problem of different datetime strings formatting between asp.net and ms sql has been covered here widely, but what I couldn't find is the 100% safe way of getting datetime...
5
by: =?Utf-8?B?RmFlc3NsZXIgR2lsbGVz?= | last post by:
Hello, I'm facing a strange problem. We have an Asp.net 2.0 Web Application and somehow the date format is changing from one client to another even if all the code is running server-side... ...
2
by: helveticus | last post by:
Is there a way to keep datetime expressions culture invariant? My app is culture dependent and contains a series of datetime settings that are saved in cookies. The cookie date strings raise...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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
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...

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.