Skip to content

Instantly share code, notes, and snippets.

@rubensayshi
Created September 24, 2012 12:28
Show Gist options
  • Save rubensayshi/3775712 to your computer and use it in GitHub Desktop.
Save rubensayshi/3775712 to your computer and use it in GitHub Desktop.
<?php
$json = array();
foreach ($dbResults as $row) {
$date = new DateTime("{$row['datefield']}");
$date->setTimezone(new DateTimeZone('UTC'));
$timestamp = $date->getTimestamp();
$json[$timestamp] = $row['value'];
}
print json_encode(array(array('name' => 'MyLine', 'data' => $json)));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment