如何设置日期时间值的时区(或实物)? [英] How to set a time zone (or a Kind) of a DateTime value?
问题描述
我的意思是存储严格的UTC时间的日期时间变量并输出ISO 8601格式。
I mean to store strict UTC time in a DateTime variable and output it in ISO 8601 format.
要做到我用的ToString(YYYY-MM-DDTHH:MM:sszzz)最后,它已发现的时区为UTC + 01:00
To do the last I've used .ToString("yyyy-MM-ddTHH:mm:sszzz"), and it has uncovered that the time zone is UTC+01:00.
我试图用.Kind = DateTimeKind.Utc,但它说Kind属性有没有setter。
I've tried to use .Kind = DateTimeKind.Utc, but it says the Kind property has no setter.
我如何明确指定的时间为UTC?是怎么样属性设置?
How do I explicitly specify the time is in UTC? How is the Kind property set?
推荐答案
虽然DateTime.Kind酒店没有一个二传手,静态方法<一href="http://msdn.microsoft.com/en-US/library/system.datetime.specifykind%28v=VS.100%29.aspx">DateTime.SpecifyKind与类指定值创建一个DateTime实例。
While the DateTime.Kind property does not have a setter, the static method DateTime.SpecifyKind creates a DateTime instance with a specified value for Kind.
Altenatively有几个 DateTime的构造函数重载一>,它接受一个DateTimeKind参数
Altenatively there are several DateTime constructor overloads that take a DateTimeKind parameter
这篇关于如何设置日期时间值的时区(或实物)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!