Untitled
unknown
plain_text
a year ago
1.0 kB
17
Indexable
using System;
using System.Globalization;
class Program
{
static void Main()
{
// Example ISO 8601 date time string
string iso8601String = "2024-08-07T12:34:56.789Z";
// Parse the ISO 8601 string to a DateTime object
DateTime parsedDateTime = DateTime.Parse(iso8601String, null, DateTimeStyles.RoundtripKind);
// Print the DateTime object
Console.WriteLine($"Parsed DateTime: {parsedDateTime}");
Console.WriteLine($"Kind: {parsedDateTime.Kind}");
// Example with offset
string iso8601StringWithOffset = "2024-08-07T12:34:56.789+07:00";
// Parse the ISO 8601 string with offset to a DateTime object
DateTime parsedDateTimeWithOffset = DateTime.Parse(iso8601StringWithOffset, null, DateTimeStyles.RoundtripKind);
// Print the DateTime object
Console.WriteLine($"Parsed DateTime with offset: {parsedDateTimeWithOffset}");
Console.WriteLine($"Kind: {parsedDateTimeWithOffset.Kind}");
}
}Editor is loading...
Leave a Comment