Convert PHP date into javascript date format

后端 未结 8 862
误落风尘
误落风尘 2020-12-06 04:45

I have a PHP script that outputs an array of data. This is then transformed into JSON using the json_encode() function.

My issue

8条回答
  •  萌比男神i
    2020-12-06 05:12

    An improvement or simplification of @jeremyharris answer would be this one:

    DateTime objects in PHP have the getTimestamp() format, use it and multiply the value by 1000:

    getTimestamp() * 1000; 
    ?>
    
    // JavaScript
    let startTime = new Date(phpDateTimeStamp);
    

提交回复
热议问题