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

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -