what kind of format is this?

I have the following DateTime string 2014-11-03 08:44:00:082467 Z

When I try to do c simple Convert.ToDateTime I got and error that it's not a recognized DateTime string.

I also tried what's suggested in the post here: DateTime.Parse("2012-09-30T23:00:00.0000000Z") always converts to DateTimeKind.Local

var date = DateTime.ParseExact("2012-09-30T23:00:00.0000000Z",
                                   "yyyy-MM-dd'T'HH:mm:ss.fffffff'Z'",
                                   CultureInfo.InvariantCulture,
                                   DateTimeStyles.AssumeUniversal |
                                   DateTimeStyles.AdjustToUniversal);

But got the same error. What kind of DateTime string is this? and how can I convert it to a DateTime object? Also, it's not the currect time (I'm 2 hours before) - so I'm guessing it's some kind of universal time.

Thanks


This is the format that applies to your string , although it is not a valid string according to the ISO 8601 standard :

var date = DateTime.ParseExact("2014-11-03 08:44:00:082467 Z",
                               "yyyy-MM-dd' 'HH:mm:ss:ffffff' Z'",
                               CultureInfo.InvariantCulture,
                               DateTimeStyles.AssumeUniversal |
                               DateTimeStyles.AdjustToUniversal);

Dotnetfiddle


它看起来像ISO 8601格式。

DateTime.Now.ToString("o")


The two dates you provide in your question are not the same at all !

Assuming your question applies to the second, which looks like to be standard, the answer is :

string s = "2012-09-30T23:00:00.0000000Z";
var date = DateTime.ParseExact(s, "o", CultureInfo.InvariantCulture,
                                   DateTimeStyles.AssumeUniversal |
                                   DateTimeStyles.AdjustToUniversal);
Console.WriteLine(date);

(full working sample)

链接地址: http://www.djcxy.com/p/46586.html

上一篇: Date.js错误地解析ISO 8601 UTC日期

下一篇: 这是什么样的格式?