自定义DateTime格式 [英] Custom DateTime format
本文介绍了自定义DateTime格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是DateTime格式2011-09-12T10:28:55Z
?
我怎样才能使用它的ToString()?
我没有得到微软的关于它的文件的任何信息。没有类似这样的。
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.
推荐答案
您可以得到使用的ToString有:
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.
当然,如果它是不是已经是一个UTC日期/时间,然后它会躺在(那是什么'Z'有点意思)。您可以拨打 DateTime.ToUniversalTime()
来转换它,当然。
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.
这篇关于自定义DateTime格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文