我试图检查时间戳记是否从今天(午夜之后)开始。
例如,这是我要检查的时间戳:1572122130
。
我尝试过的事情:
<?php
$time = strtotime('today midnight') - 1572122130;
if($time < 86400){
echo "timestamp is from today!"; //timestamp is from today (after midnight)
}
答案 0 :(得分:0)
您可以简单地使用DateTime
类。
$ts = 1572122130;
$today = (new \DateTime())->setTime(0, 0); // get tonight midnight
// compare the timestamp to the date above
var_dump(date_create_from_format('U', $ts) >= $today);