Home forums Using CanvasJS Help with Spline Chart

This topic contains 4 replies, has 2 voices, and was last updated by  Vishwas R 3 months, 2 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #22088

    I understand about using the chart with php my only question is how to convert the Date to Timestamp in the format you use?

    #22092

    Vishwas R
    Keymaster

    @lonster_monster,

    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.

    $phpDate = date("Y-m-d h:i:sa");
    $phpTimestamp = strtotime($phpDate);
    $javaScriptTimestamp = $phpTimestamp * 1000;


    Vishwas R
    Team CanvasJS

    #22093

    Would i do it like this in my php
    array_push($dataPoints, array("x"=> $row->strtotime(Date)*1000, "y"=> $row->Profits));

    #22094

    I got it thanks i use
    array_push($dataPoints, array(“x”=> $PHPstr=strtotime($row->Date)*1000, “y”=> $row->Profits));

    #22095

    Vishwas R
    Keymaster

    @lonster_monster,

    Glad that it works :)


    Vishwas R
    Team CanvasJS

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

You must be logged in to reply to this topic.