Jason
Jason

Reputation: 393

Highcharts Single Line series JSON date data format

I am trying to implement the Single Line series chart here: http://www.highcharts.com/stock/demo/basic-line

I see the JSON format for the report is as follows:

/* May 2006 */
[1147651200000,67.79],
[1147737600000,64.98],
[1147824000000,65.26],
[1147910400000,63.18],
[1147996800000,64.51],
[1148256000000,63.38],
[1148342400000,63.15],
[1148428800000,63.34],
[1148515200000,64.33],
[1148601600000,63.55],
[1148947200000,61.22],
[1149033600000,59.77],

How do I change my data format of [date, count] into the format above?

eg my format ["2013-01-01", 55],

Thanks for any light you can shed.

Upvotes: 1

Views: 1955

Answers (2)

Rid Iculous
Rid Iculous

Reputation: 3962

In PHP do this:

 $timestamp =  1000 * strtotime($your_date);

Upvotes: 0

SteveP
SteveP

Reputation: 19093

There is a javascript function Date.UTC which will do the conversion for you. e.g.

[Date.UTC(2013,0,1),55],

Note, the Javascript months start at 0 (for Jan), not 1.

N.B. Make sure your axis type is 'datetime'.

Upvotes: 1

Related Questions