I’m fetching dates from MySQL as strings (Y-m-d format). I need to display a chart using Highcharts. Highcharts uses javascript Date.UTC function:
Return the number of milliseconds between a specified date and
midnight January 1 1970.
data: [
[Date.UTC(1970, 9, 27), 0 ],
[Date.UTC(1970, 10, 10), 0.6 ],
[Date.UTC(1970, 10, 18), 0.7 ],
[Date.UTC(1970, 11, 2), 0.8 ],
[Date.UTC(1970, 11, 9), 0.6 ],
But i’d like to avoid javascript and do in in PHP (assigning a JSON object – the chart – to the page itself). What’s the equivalent of Date.UTC function in PHP (regardless the server datezone)?
$date = '2012-07-07';
$millisecs = 1000 * unix_timestap_utc_regardless_server_zone($date);
I would use
That would set $today as the date.
EDIT: Niclas is also right, this is just how I would do it.
EDIT 2: You can replace getdate() with a valid timestamp in PHP, if you like…
EDIT 3: Sorry… Misunderstanding… use strtotime() to make a valid timestamp!