I am having problems converting a string in the format "yyyy-MM-ddZ" using VB.net.
For example I have the string "2007-10-21Z".
Using CDate or TryParse it comes out to 10/20/2007 instead of 10/21/2007.
I'm not understanding how the Z affects the date string so that when it is parsed it results in the day before.
From what I understand Z specifies the zero timezone. But the date string has no time information. How does this work?
It's interpreting the date as midnight Zulu (GMT) time and then converting it back to your local time zone. If you're in the States that would be between 3:00PM to 7:00 PM in the previous day.
Try
DateTime.ParseExact("2007-10-21Z", "yyyy-MM-ddZ", CultureInfo.InvariantCulture);
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