在PHP中获取今天和昨天的时间戳
问题描述:
如何通过使用php中的strtotime()函数获取今天,昨天和前天的12点时间戳?
How can I get the timestamp of 12 o'clock of today, yesterday and the day before yesterday by using strtotime() function in php?
12点是一个变量,将由用户更改.
12 o'clock is a variable and would be changed by user.
答
$hour = 12;
$today = strtotime($hour . ':00:00');
$yesterday = strtotime('-1 day', $today);
$dayBeforeYesterday = strtotime('-1 day', $yesterday);