By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,215 Members | 1,920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,215 IT Pros & Developers. It's quick & easy.

datetime culture problems

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.