Home Forums Chart Support Date using PHP Reply To: Date using PHP

#23054

@don-leesuccessrocket-io,

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, you need to set xValueType to ‘dateTime’ as x-value will be in timestamp.

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

Chart with Timestamp Values on X-axis

If this doesn’t solve your requirement, kindly share a sample project along with sample database over Google Drive or Onedrive reproducing the issue your are facing, so that we can look into your code, understand it better and help you out.

__
Priyanka M S
Team CanvasJS