datetime culture problems

  • Thread starter Thread starter adam
  • Start date Start date
A

adam

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
 
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 ]
 
Back
Top