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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -