龍巖易富通網(wǎng)絡(luò)科技有限公司

龍巖小程序開發(fā),龍巖分銷系統(tǒng)

php與js時(shí)間戳相互轉(zhuǎn)換

2018.09.12 | 1783閱讀 | 0條評(píng)論 | javascript

php方法 time();獲取現(xiàn)在時(shí)間 得到 10位數(shù)

js new Date();獲取現(xiàn)在時(shí)間 Date.getTime() ; 得到13位數(shù)字

new Date('13位的數(shù)字');得到現(xiàn)在時(shí)間的Date對(duì)象;

php傳到j(luò)s的時(shí)間戳 要*1000可以正確解讀;


var time = new Date(parseInt(phptime)*1000)  //php轉(zhuǎn)換js

var time = Date.parse(new Date())/1000   //js轉(zhuǎn)換php


贊 (

發(fā)表評(píng)論