Date Formats

  • Thread starter Thread starter Ian Frawley
  • Start date Start date
I

Ian Frawley

anyone know how to get this working?

string ergggg = "20051201 162533";
DateTimeFormatInfo myDTFI = new CultureInfo( "en-Gb",
false ).DateTimeFormat;
myDTFI.FullDateTimePattern = "yyyyMMdd hhmmss";
DateTime switchdate = DateTime.ParseExact(datething,"yyyyMMdd hhmmss",
myDTFI);
string ace = switchdate.ToString();
 
Ian,

You want to use this instead:

myDTFI.FullDateTimePattern = "yyyyMMdd HHmmss";
DateTime switchdate = DateTime.ParseExact(datething,"yyyyMMdd HHmmss",
myDTFI);

Note the capital H. This will interpret the hour as military time,
instead of am/pm.

Hope this helps.
 
in message

Hi Nicholas,

Bingo thats fixed me problem many many thanks.

Ian
Ian,

You want to use this instead:

myDTFI.FullDateTimePattern = "yyyyMMdd HHmmss";
DateTime switchdate = DateTime.ParseExact(datething,"yyyyMMdd HHmmss",
myDTFI);

Note the capital H. This will interpret the hour as military time,
instead of am/pm.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Ian Frawley said:
anyone know how to get this working?

string ergggg = "20051201 162533";
DateTimeFormatInfo myDTFI = new CultureInfo( "en-Gb",
false ).DateTimeFormat;
myDTFI.FullDateTimePattern = "yyyyMMdd hhmmss";
DateTime switchdate = DateTime.ParseExact(datething,"yyyyMMdd hhmmss",
myDTFI);
string ace = switchdate.ToString();

--

Regards

Ian Frawley
 
Back
Top