Why can't DateTime.Parse parse UTC date

why can't
why can't i liz phair movie
why can't i lyrics
why can't i lyrics meaning
why can't we be friends
why can't you read my mind pdf
why can't i transfer money from paypal to my bank account
liz phair - extraordinary

Why can't it parse this:

DateTime.Parse("Tue, 1 Jan 2008 00:00:00 UTC")

It can't parse that string because "UTC" is not a valid time zone designator.

UTC time is denoted by adding a 'Z' to the end of the time string, so your parsing code should look like this:

DateTime.Parse("Tue, 1 Jan 2008 00:00:00Z");

From the Wikipedia article on ISO 8601

If the time is in UTC, add a 'Z' directly after the time without a space. 'Z' is the zone designator for the zero UTC offset. "09:30 UTC" is therefore represented as "09:30Z" or "0930Z". "14:45:15 UTC" would be "14:45:15Z" or "144515Z".

UTC time is also known as 'Zulu' time, since 'Zulu' is the NATO phonetic alphabet word for 'Z'.

Why Can't You Read My Mind? Overcoming the 9 Toxic Thought , Why Can't You Read My Mind? Overcoming the 9 Toxic Thought Patterns that Get in the Way of a Loving Relationship [Bernstein Ph.D., Jeffrey] on Amazon.​com. When you get a message that says Windows can't be activated, there are several possible reasons why. Select any of the following topics to see some typical reasons for activation difficulty, along with possible ways to get going again.

Assuming you use the format "o" for your datetime so you have "2016-07-24T18:47:36Z", there is a very simple way to handle this.

Call DateTime.Parse("2016-07-24T18:47:36Z").ToUniversalTime().

What happens when you call DateTime.Parse("2016-07-24T18:47:36Z") is you get a DateTime set to the local timezone. So it converts it to the local time.

The ToUniversalTime() changes it to a UTC DateTime and converts it back to UTC time.

Amazon.com Help: Why Can't I Log into My Account?, If you're having trouble logging in, you may be entering incorrect account information or you may need to reset your password. Here are some things to check:. Being overweight, getting too little exercise, and smoking all can work against the good blood flow that is key to erections. For some men, a little alcohol may help take the edge off.

Just use that:

var myDateUtc = DateTime.SpecifyKind(DateTime.Parse("Tue, 1 Jan 2008 00:00:00"), DateTimeKind.Utc);

if (myDateUtc.Kind == DateTimeKind.Utc)
{
     Console.WriteLine("Yes. I am UTC!");
}

You can test this code using the online c# compiler:

http://rextester.com/

I hope it helps.

The Royals are paying everyone. Why can't all of the other teams , That's the decision in which the Supreme Court ruled that federal antitrust laws did not apply to baseball because, in the mind of Justice Oliver  And I can't recall any love at all Oh baby, this blows 'em all away It's got what it takes So tell me why can't this be love? Straight from my heart Oh tell me why Can't this be love? I tell

You need to specify the format:

DateTime date = DateTime.ParseExact(
    "Tue, 1 Jan 2008 00:00:00 UTC", 
    "ddd, d MMM yyyy HH:mm:ss UTC", 
    CultureInfo.InvariantCulture);

Why can't I transfer money to my bank?, Due to coronavirus (COVID-19) safety precautions, we currently have limited customer service staffing so wait times may be longer. You can still view answers to  Can’t go? You’re not alone. About 20% of Americans have occasional constipation-- bowel movements less than three times a week.Or if they do poop, the output is hard, small, and painful to

or use the AdjustToUniversal DateTimeStyle in a call to

DateTime.ParseExact(String, String[], IFormatProvider, DateTimeStyles)

Why can't I link a bank account to my PayPal account?, Due to coronavirus (COVID-19) safety precautions, we currently have limited customer service staffing so wait times may be longer. You can still view answers to  A brand-new version of Facebook Messenger has dropped for iOS, and while I appreciate Facebook’s newfound interest in keeping the app svelte, I think the cuts have gone too deep. You’ll no

Why can't I access certain features, such as Flirting skill, forums or , There are privacy settings and legal requirements that may restrict access to certain features on Duolingo. You may have enabled If people can't hear you on your iPhone or Siri can't process your requests, one of your iPhone's microphones may be malfunctioning.

Boost Unavailable on Facebook, Why Is My Post Type Unsupported? Why is my boost unavailable? To learn more about why your boost is unavailable or how you can boost a similar post,  There could be several reasons why you aren't receiving your e-mail messages. Please review the following situations to see if one applies to you: Did you just move your domain name to Network Solutions® or register a new domain name? If so, it will take approximately 12-36 hours for the domain name information to propagate to servers worldwide.

I can't access Marketplace. | Facebook Help Center, I can't access Marketplace. shareShare Article. Marketplace isn't available to everyone right now. First, try visiting Marketplace from this link. If the link doesn't  You can help protect yourself from scammers by verifying that the contact is a Microsoft Agent or Microsoft Employee and that the Why can't I access yahoo.com?

Comments
  • IE9 is still incorrectly adding "UTC" when you use new Date().toUTCString() in Javascript
  • For anyone coming to this post 2009, the answer to this issue is momentjs.com
  • The date string in my example came from internet explorer
  • @Dave: When you say it came from IE, do you mean that you extracted it from a web page? You may have to write your own replacement for the DateTime parser that extracts the UTC and replaces it with a Z.
  • Having being testing against FF, I had forgotten I called the toUTCString() method on the date I POST back to the server. FF sends GMT while IE sends UTC. So I cant blame IE... this time!
  • As other answers point out, the UTC date string with Z designator would indeed be successfully parsed, but it would also be converted to local time, i.e. it returns DateTime with a Kind of Local and adjusted timestamp. To always get UTC DateTime, one could use one of DateTime.Parse("2008-01-01 00:00:00Z", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal), as @crokusek suggests, or DateTimeOffset.Parse("2008-01-01 00:00:00Z").UtcDateTime, as @ruffin suggests.
  • In meta tag like http-equiv="last-modified" the format is 2013-10-23@17:23:00 UTC, is it possible?
  • Nice suggestion, but this would fail if the provided date string didn't contain UTC at the end. Say instead you passed a date string that had +01 at the end, it would cause a FormatException. Depends what he is trying to do I suppose.
  • This actually works. I used this code and got correct UTC DateTime from UTC string: DateTime.TryParseExact("2012-01-30T00:28:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out timeValue));
  • This one works too, Utc in and out, no format, no Z required: DateTime.Parse("8/3/2013 1:02:41 AM", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal);
  • I was dealing with a UTC time string similar to Roboblob, and used code similar to what Roboblob specified to maintain the UTC-ness of the value: DateTime.ParseExact(utcTimeStringINeededToParse, "yyyy-MM-ddTHH:mm:ss.0000000Z", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AdjustToUniversal)
  • According to the docs, "the Kind property of the returned DateTime value is DateTimeKind.Local." ParseExact correctly parses it as UTC, but then converts it to local time before returning it. Use DateTimeStyles.RoundtripKind if you want the returned value to be returned unmodified as UTC.
  • A simple replace of "UTC" with "GMT" in a date string similar to this format works great, thanks for the tip.
  • Though note that this returns a DateTime with a Kind of Local for me. Looks like the workaround is to use DateTimeOffset.Parse (and then x.UtcDateTime) if you want to ensure you're not falling off of the UTC wagon during your parse.
  • ToUniversalTime never throws an exception