I'm trying create UTC date, but it seem to one month off. I guess it is because it is zero based.
how can i minus one month in a code like this?
$data = array();
foreach ($balanceQuery as $row)
{
$value = $row->balance;
$datetime1 = date('Y, n, j', strtotime($row->post_date));
$datetime = 'Date.UTC('. $datetime1 .')';
$data[] = "[$datetime, $value]";
}
If you want the post date in milliseconds since the Unix epoch just use PHP DateTime functionality:
$datetime = (new DateTime($row->post_date))->getTimestamp();
If you want to subtract one month you can do this:
$datetime = (new DateTime($row->post_date))->modify('-1 month')->getTimestamp();
Now to convert it to milliseconds either multiply by 1000 or append three zeros (as a string). I think multiplying it by a thousand may cause the integer to become too large for your system so appending three zeros may be your safest bet.