How would I convert this array to usable javascript array?

I have php code that returns this from a database,

[
{
    "Time": "2012-11-27 16:10:35",
    "NumPlayers": "1"
},
{
    "Time": "2012-11-27 16:24:55",
    "NumPlayers": "1"
},
{
    "Time": "2012-11-27 16:25:37",
    "NumPlayers": "2"
},
{
    "Time": "2012-11-27 16:29:33",
    "NumPlayers": "2"

The times are MySQL timestamps. I need to get it into this format to use with Highcharts javascript charting.

data: [
[Date.UTC(1970,  9,  9), 0   ],
[Date.UTC(1970,  9, 14), 0.15],
[Date.UTC(1970, 10, 28), 0.35],
[Date.UTC(1970, 11, 12), 0.46],

I’m having trouble figuring out how to loop through the MySQL results and convert the timestamps to javascript Date.UTC objects. I need to place the NumPlayers value after the Date.UTC objects, and output it in the format below. I’m a PHP and javascript noob :\

It should look something like this:

data: [
[Date.UTC(2012, 11, 27, 16, 10, 35), 1],
[Date.UTC(2012, 11, 27, 16, 24, 55), 1],
[Date.UTC(2012, 11, 27, 16, 25, 37), 2],
[Date.UTC(2012, 11, 27, 16, 29, 33), 2],

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories