Home › forums › Chart Support › Getting DateTime value from mysql db to create a chart
Tagged: DateTime value from mysql db
Hi I am querying mysql database for two values datetime (format: 2018-04-18 11:47:53) and a number values (100 … etc) to create a chart, I am trying to use the below code but its not working, is there any other way I can create this chart, sorry I am also new to php and charting
$vsql = “SELECT Datetime, value FROM x $result = mysqli_query($con,$vsql); $dataPoints1 = array();
while ($row = mysqli_fetch_array($result)) { $entry = (strtotime($row[0])*1000) .’, ‘.$row[1]; array_push($dataPoints1, $entry); } }
@d77info,
Kindly download the sample PHP project from this link.
The above sample shows how to pass dateTime from a database into Charts in PHP. A ReadMe file has been included for your convenience with all the instructions to set up the project.
Also kindly set the xValueType: "dateTime" as timestamp values are getting assigned to the chart instead of Date objects.
xValueType: "dateTime"
____________ Indranil Deo, Team CanvasJS
You must be logged in to reply to this topic.