Home Forums Chart Support Date pass throw php

Date pass throw php

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

    i want to pass date in array but it not pass correctly please help me
    I used this one

    array_push($dataPoints_1, array(“x”=> ‘new Date(‘.$year.’, ‘.$month, “y”=> $order_total));

    #37105

    @umeshkrishna,

    In order to convert PHP date to Charts (JavaScript timestamp), 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 as shown below,

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

    You also need to set xValueType property to ‘dateTime’ as x-value will be a timestamp.

    Chart with PHP timestamp values

    __
    Adithya Menon
    Team CanvasJS

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

You must be logged in to reply to this topic.