Timestamp between Javascript and PHP

后端 未结 3 965
春和景丽
春和景丽 2020-12-15 04:43

Javascript:

I have object cell with something date

params.date = cell.getDate();
params.timestamp = cell.getDate().getTime() / 1000;
console.log(para         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-15 05:10

    When you get timestamp from Javacript date object :

    it output will be interms of milli-seconds

     
    

    output : 1386746353000

    Where as php date object timestamp interms of seconds

    getTimestamp();
         ?>
    

    output : 1386746353

    So when you are going to use javascript date object timestamp with php date object you should divide timestamp of javascript by 1000 and use it in php

提交回复
热议问题