Home forums Using CanvasJS How to Change date format for PHP

Tagged: , ,

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

    Hello,
    i try to use the “PHP Spline Charts & Graphs” to show daily sales report of the month. We have a target and on daily basic i we go near the target each day of month the graph increase. But in the x value you are passing date in different format like “array(“x” => 946665000000, “y” => 3289000),” how can i convert my date into that format? please help. in PHP i have the date like “2020-03-05” so now need to convert it to that format.

    #28587

    @salman_emenacsoft,

    To convert PHP date to JavaScript timestamp, first, you need to convert PHP date to PHP timestamp using strtotime and then convert PHP timestamp to JavaScript timestamp by multiplying PHP timestamp by 1000. Also, setting xValueType to ‘dateTime’ should work fine in your case.

    $phpTimestamp = strtotime("2020-03-05");
    $javaScriptTimestamp = $phpTimestamp * 1000;

    __
    Vishwas R
    Team CanvasJS

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

You must be logged in to reply to this topic.