Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ISO 8601 into a datetime object using C# [duplicate]

Tags:

.net

Possible Duplicate:
How to create a .NET DateTime from ISO 8601 format

How can I parse a date string in ISO 8601 format into a datetime object using C#?

like image 434
Marvin Garcia Avatar asked Mar 19 '26 20:03

Marvin Garcia


1 Answers

Use one of the ISO 8601 standard date and time format strings - "O", "o" , "S" and "s" when parsing the string (aka the Roundtrip format specifier) .

The pattern for this specifier reflects a defined standard (ISO 8601). Therefore, it is always the same regardless of the culture used or the format provider supplied.

DateTime dt = DateTime.ParseExact(iso8601String, "s", CultureInfo.InvariantCulture);
like image 85
Oded Avatar answered Mar 22 '26 12:03

Oded



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!