Home forums Chart Support Getting DateTime value from mysql db to create a chart

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #21361

    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);

    • This topic was modified 2 years, 6 months ago by 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.

    Indranil Deo,
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.