Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert data into DateTime object

How do I convert a date string, in the general form of "ccyymmdd" in to a DateTime object in C#?

For example, how would I convert "20100715" in to a DateTime object.

Please - No RTFM links to Microsoft Tech Docs.

Many Thanks...

like image 525
logout Avatar asked May 05 '26 08:05

logout


1 Answers

using System.Globalization;

DateTime.ParseExact("20100715", "yyyyMMdd", CultureInfo.InvariantCulture);
like image 157
Mike Powell Avatar answered May 06 '26 23:05

Mike Powell