Convert PHP date into javascript date format

后端 未结 8 854
误落风尘
误落风尘 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条回答
  • 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:

    <?php 
        $phpDateTimeStamp = new Date('Y/m/d H:i:s')->getTimestamp() * 1000; 
    ?>
    
    // JavaScript
    let startTime = new Date(phpDateTimeStamp);
    
    0 讨论(0)
  • 2020-12-06 05:12
    $newticket['DateCreated'] = date('d-m-Y G:H', strtotime($phpDateVariable));
    
    0 讨论(0)
提交回复
热议问题