The DataTable constructor expects dates to be passed as a string with this 
format:

"Date(year, month, day, hour, minute, second)"

note that months are zero-index in js, so you have to subtract 1.

This would probably work:

$sth = mysql_query("SELECT * FROM testpower WHERE datetime > 0");
$rows = array();
$flag = true;

$table = array();

$table['cols'] = array(

    array('label' => 'date', 'type' => 'datetime'),

    array('label' => 'power', 'type' => 'number')

);

$rows = array();
while($r = mysql_fetch_assoc($sth)) {
    $temp = array();

    $dateTimeArr = explode(' ', $i['datetime']);

    $dateArr = explode('-', $dateTimeArr[0]);

    $timeArr = explode(':', $dateTimeArr[1]);

$year = $dateArr[0];
$month = $dateArr[1] - 1; // months are zero-indexed
$day = $dateArr[2];
$hour = $timeArr[0];
$min = $timeArr[1];
$sec = $timeArr[2];
$temp[] = array('v' => "Date($year, $month, $day, $hour, $min, $sec)";
$temp[] = array('v' => (int) $i['power']);

    $rows[] = array('c' => $temp);
}

$table['rows'] = $rows;

$jsonTable = json_encode($table);



On Monday, July 16, 2012 4:06:15 PM UTC-4, shown wrote:
>
> Is the Date/datetime object possible to instantiate with a literal?  Did 
> you mean Date() by transform?  Literal:  "" or '' or   ?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/Pow4HUKey3wJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to