My goal is to convert a timestamp from MySQL into a JavaScript Date object in an efficient manner. Here is my current snippet that converts the MySQL timestamp into a formatted date in PHP:
<?php
// formats timestamp into following format: 2009, 7, 30
$date = date("Y, n, j", strtotime($row["date"]));
?>
I am then using this $date
value for a chart using Google's charting API which requires JavaScript Date object:
data.setValue(<?=$count;?>, 0, new Date(<?=$date;?>));
The problem is that the JavaScript Date object begins the month index with 0 so the output is always 1 month in advance. What is the most efficient way in dealing with this issue?
Thanks in advance!
See Question&Answers more detail:os