How to set a time zone (or a Kind) of a DateTime value?

前端 未结 3 429
-上瘾入骨i
-上瘾入骨i 2020-12-29 18:15

I mean to store strict UTC time in a DateTime variable and output it in ISO 8601 format.

To do the last I\'ve used .ToString(\"yyyy-MM-ddTHH:mm:sszzz\"), and it has

3条回答
  •  没有蜡笔的小新
    2020-12-29 18:47

    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 there are several DateTime constructor overloads that take a DateTimeKind parameter

提交回复
热议问题