c# - DateTime check if it is in UTC format -
i have question date time format.
have string, represents datetime: "2014-08-01t10:12:11.0z". actually, understand, datetime in utc format, because 'z' shows me offset utc.
and try perform
datetime.tryparseexact("2014-08-01t10:12:11.0z", "yyyy-mm-ddthh:mm:ssz", cultureinfo.invariantculture, datetimestyles.adjusttouniversal, out value_);
(where value_ newly created datetime object) check if string represents utc time. expression gives me 'false'.
so, wonder, format should pass instead of "yyyy-mm-ddthh:mm:ssz" or should change else?
the .0
@ end of string tenths of seconds, need add parse character it: f
.
also, parse character z k
, not z
.
so parse string need this:
datetime.tryparseexact("2014-08-01t10:12:11.0z", "yyyy-mm-ddthh:mm:ss.fk", cultureinfo.invariantculture, datetimestyles.adjusttouniversal, out value);
also note if want time zone information in string parsed (i.e. if wasn't utc time), z
replaced timezone offset, +ve or -ve:
"2014-08-01t10:12:11.0-07:00" // note time zone offset @ end.
Comments
Post a Comment