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") 

datetime formatting options


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -