Home forums Using CanvasJS Date using PHP Reply To: Date using PHP

#23054

Priyanka M S
Member

@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, setting xValueType to ‘dateTime’ should work fine in your case.

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

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