I'm trying to parse the date from the Last-Modified header in an HTTP response.
The date shows as follow:
Last-Modified: Sat, 01 Jul 2006 01:50:55 UTC
I tried DateTime.Parse, DateTime.ParseExact with no success.
What is that UTC thing at the end and why does C# doesn't want to parse it?
Update:
Use ParseExact
to specify the input format:
string inputDate = "Sat, 01 Jul 2006 01:50:55 UTC";
DateTime time = DateTime.ParseExact(inputDate,
"ddd, dd MMM yyyy HH:mm:ss 'UTC'",
CultureInfo.InvariantCulture.DateTimeFormat,
DateTimeStyles.AssumeUniversal);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With