嘗試用php的兩種方式取得目前的時(shí)間戳,存在差異,但是兩個(gè)時(shí)間戳轉(zhuǎn)換成時(shí)間確是想同的時(shí)間點(diǎn),查了一下網(wǎng)路上的時(shí)間戳的單位是秒。為什麼會(huì)這樣呢?
$currentDay = getdate();
//var_dump($currentDay);
//2.1 獲取當(dāng)前的日期
//echo $currentDay["year"]."-".$currentDay["mon"]."-".$currentDay["mday"]."<br/>";
echo "時(shí)間戳為1:".strtotime(date("Y-m-d h:m:s"))."<br/>";
echo "時(shí)間戳為2:".$currentDay[0]."<br/>";
$time1 = strtotime(date("Y-m-d h:m:s"));
echo "不同的時(shí)間為:".date("Y-m-d H:m:s a",$currentDay[0])."--".date("Y-m-d H:m:s a",$time1);
輸出結(jié)果為:
時(shí)間戳為1:1492131843
時(shí)間戳記為2:1492134903
不同的時(shí)間為:2017-04-14 09:04:03 am--2017-04- 14 09:04:03 am
strtotime(date("Y-m-d h:m:s"))
應(yīng)該是:
strtotime(date("Y-m-d h:i:s"))