Skip Navigation LinksHome Page > Forums > SpiraTeam Forums > SpiraTeam Issues & Qu... > REST json Date property f...
Hi Predrag
SpiraTeam uses the WCF JSON serialization library from Microsoft .NET to convert dates into JSON. You can read more about this format here.
Basically, Dates in SpiraTeam are represented in JSON as "\/Date(number of ticks)\/".
The number of ticks is a positive or negative long value that indicates the number of ticks (milliseconds) that have elapsed since midnight 01 January, 1970 UTC.
Regards
Jim
The JSON specification does not specify a format for exchanging dates which is why there are so many different ways to do it. The problem with dates in JSON and JavaScript in general – is that there's no equivalent literal representation for dates. In JavaScript/jQuery following Date constructor straight away converts the milliseconds since 1970 to Date as follows: var jsonDate = new Date(1297246301973);
Then let's convert it to js format:
var date = new Date(parseInt(jsonDate.substr(6)));
The substr() function takes out the /Date( part, and the parseInt() function gets the integer and ignores the )/ at the end. The resulting number is passed into the Date constructor .
For ISO-8601 formatted JSON dates, just pass the string into the Date constructor:
var date = new Date(jsonDate);
And if you have any questions, please email or call us at +1 (202) 558-6885