c# - Given a DateTime object, how do I get an ISO 8601 date in string format? -
given:
datetime.utcnow
how string represents same value in iso 8601-compliant format?
note iso 8601 defines number of similar formats. specific format looking is:
yyyy-mm-ddthh:mm:ssz
datetime.utcnow.tostring("yyyy-mm-ddthh\\:mm\\:ss.fffffffzzz");
this gives date similar 2008-09-22t13:57:31.2311892-04:00.
another way is:
datetime.utcnow.tostring("o");
which gives 2008-09-22t14:01:54.9571247z
to specified format, can use:
datetime.utcnow.tostring("yyyy-mm-ddthh:mm:ssz")
Comments
Post a Comment