DateTime convert

  • Thread starter Thread starter Ha ha
  • Start date Start date
Use the ToString() method...

DateTime myTime = DateTime.Now;
string myTimeSting = myTime.ToString ( "yyyyMMddHHmm");
 
Ha said:
How can I convert a string like '200412240000' to a DateTime type.

DateTimeFormatInfo myDTFI = new DateTimeFormatInfo();
myDTFI.ShortDatePattern = "yyyyMMddHHmm";
DateTime dt = DateTime.Parse(pDateString, myDTFI);


Hans Kesting
 
How can I convert a string like '200412240000' to a DateTime type.

DateTime date = DateTime.ParseExact("200412240000"
, "yyyyMMddHHmm"
, new DateTimeFormatInfo());
 
Hi,

DateTime.ParseExact

What the trailing 4 ceros means?

Cheers,
 
Hi,

I think he wants the opposite , from string to datetime

Cheers,
 
Back
Top