DateTime Format

Follow

DateTime Format

The format for datetimes in this API follows the ISO 8601 format. This format will work when passed in for the query syntax as well as on request bodies for POST/PUT requests.

There are a couple of common variations to this format: one with the timezone offset, and one without.

UTC
2014-05-12T00:00:00.0Z
Local Time
2014-05-13T06:00:00.000-06:00

From Code

CSharp

Libraries like RestSharp and JSON.NET will handle this format for you.

DateTime.UtcNow.ToString("s")   // NOTE: DateTime.Now.ToString("s") will give local time without the offset
DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ss.FFFFFFK")
Python
>>> from datetime import datetime
>>> datetime.utcnow().isoformat()
'2014-05-12T14:51:02.206277'
Ruby
irb(main):001:0> require 'time'
=> true
irb(main):002:0> Time.now.iso8601
=> "2014-05-12T09:47:09-05:00"
irb(main):003:0> Time.now.utc.iso8601
=> "2014-05-12T14:47:16Z"
node.js
> var date = new Date();
undefined
> date.toISOString();
'2014-05-12T14:53:34.524Z'
Have more questions? Submit a request

Comments