Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New to Json/Java - what datatype is this? A datetime? 13 digits long. Using PHP

I'm experimenting/learning with java and json. I'm trying to make my own data for a json parser and I can't figure out what datatype the example data it gives me is. I think it's a datetime, but I don't know how to get my date (regular format) to the json date format. I'm coding the example using PHP.

Jsonp Example Data:

[1110844800000,178.61],
[1110931200000,175.60],
[1111017600000,179.29],

My Date and Data format:

2012-03-01 18:21:31,42
2012-03-01 18:22:31,46
2012-03-02 18:21:31,40

Does anyone know if the 13 digit date/time json above is a datetime specific to java or json? And if so, how to get my data to that format?

Thanks!

like image 824
CREW Avatar asked Mar 13 '12 20:03

CREW


2 Answers

It looks like the Javascript version of Unix time, which is really just Unix time in milliseconds rather than seconds.

Divide your 13-digit numbers by 1000 and run them through this site to verify: http://www.onlineconversion.com/unix_time.htm

like image 112
gregheo Avatar answered Sep 30 '22 05:09

gregheo


Each of what you've quoted is an array with two entries. The first entry in each array might be a datetime. If so:

1110844800000 = Tue, 15 Mar 2005 00:00:00 GMT
1110931200000 = Wed, 16 Mar 2005 00:00:00 GMT
1111017600000 = Thu, 17 Mar 2005 00:00:00 GMT

JavaScript stores date/times as milliseconds since The Epoch (midnight on 1 Jan 1970 GMT), so to convert to Date instances:

var dt = new Date(1110844800000);

...which is how I got the values above.

No idea what the second entry in each array is. It looks like a currency (money) figure.

like image 22
T.J. Crowder Avatar answered Sep 30 '22 04:09

T.J. Crowder