Dates in JSON

What format is the right one in JSON? "Or best? Is there any sort of standard on this?"

"DateTimes in JSON are hard.

The problem comes from the JSON spec itself: there is no literal syntax for dates in JSON. The spec has objects, arrays, strings, integers, and floats, but it defines no standard for what a date looks like."

A common date/time-format used is ISO 8601. It is also used widely in libraries such as JavaScript's toJSON-method and Json.NET.

In principle this turns the DateTime string into:
<YYYY-MM-DD>T<HH:MM>[:SS.SSS][[+|-]HH:MM[:SS]|Z]


Example:


  {
	  "lastPlayedDateTime": "2021-12-28T23:30:00+01:00"
  }


What's the Z?

Z depicts the shorthand notation for UTC times, e.g. "2009-02-15T00:00Z".


Sources:

Comments

Popular posts from this blog

SQL Server Setup: Windows Firewall warning (Ports)

SQL Server 2014 Enterprise Edition: Server Setup: Feature Selection

How to read an assembly.dll.config