There are differences between the two methods of obtaining timestamps in PHP. Why?
给我你的怀抱
给我你的怀抱 2017-05-16 13:14:11
0
5
632

Try to use two methods of php to obtain the current timestamp. There are differences, but the two timestamps are converted into time at the same time point. I checked the unit of the timestamp on the network is seconds. Why is this happening?


$currentDay = getdate();
//var_dump($currentDay);
//2.1 获取当前的日期
//echo $currentDay["year"]."-".$currentDay["mon"]."-".$currentDay["mday"]."<br/>";
echo "时间戳为1:".strtotime(date("Y-m-d h:m:s"))."<br/>";
echo "时间戳为2:".$currentDay[0]."<br/>";
$time1 = strtotime(date("Y-m-d h:m:s"));
echo "不同的时间为:".date("Y-m-d H:m:s a",$currentDay[0])."--".date("Y-m-d H:m:s a",$time1);

The output result is:
The timestamp is 1:1492131843
The timestamp is 2:1492134903
The different times are: 2017-04-14 09:04:03 am--2017-04- 14 09:04:03 am

给我你的怀抱
给我你的怀抱

reply all(5)
伊谢尔伦
strtotime(date("Y-m-d h:m:s"))

should be:

strtotime(date("Y-m-d h:i:s"))
刘奇

It is recommended that the poster read more php manual. Link

漂亮男人

https://www.bytelang.com/o/s/...

You wrote it wrong yourself!

巴扎黑

You wrote it wrong yourself

左手右手慢动作

Year, month, day, hours, minutes and seconds correspond to Y-m-d h:i:s

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template