Custom DateTime format

夙愿已清 提交于 2019-12-24 07:18:34

问题


What's the DateTime format "2011-09-12T10:28:55Z"? How can I get it using ToString()? I didn't get any information in Microsoft's documents about it. Nothing similar like this.


回答1:


You can get that using ToString with:

var text = date.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'",
                         CultureInfo.InvariantCulture);

I don't believe there's a standard date/time format which covers this, unfortunately.

Of course, if it's not already a UTC date/time then it'll be lying (that's what the 'Z' bit means). You can call DateTime.ToUniversalTime() to convert it, of course.



来源:https://stackoverflow.com/questions/10581487/custom-datetime-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!