php - Highcharts with date and time for x axis (from a database with format YYYYMMDDHHMM) -


i trying draw graph using highcharts values time , date x axis. database has date values yyyymmddhhmm (201409011345) , want plot y values date , time. code follows ;

<?php while ($row = mysql_fetch_array($result)) {    extract $row;    $data[] = "[$datetime, $value]"; //here $datetime 201405242625 (yyyymmddhhmm) } ?> var chart = new highcharts.chart({       chart: {          renderto: 'container'       },       series: [{          data: [<?php echo join($data, ',') ?>]       }] }); 

please give me suggestions correct datetime values x axis

thanks

your date value needs either in epoch format, or date.utc object.

i'm not sure how php understand date format, assuming can, can use strtotime() function.

in case, be

$date_stamp = strtotime($datetime) * 1000 

you need * 1000 because php uses epoch time in seconds, javascript uses milliseconds.

if php has hard time interpreting date format, may need format within database query, or use php's substr() function break components , rebuild readable date format.

references:


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -