【发布时间】:2011-06-09 04:40:44
【问题描述】:
在 PHP 中,我如何获取从 now() 到下周日午夜的秒数?
我不想要相对于特定日期的解决方案,而只是到下周日。
【问题讨论】:
在 PHP 中,我如何获取从 now() 到下周日午夜的秒数?
我不想要相对于特定日期的解决方案,而只是到下周日。
【问题讨论】:
$seconds = strtotime('next Sunday') - time();
【讨论】:
你可以使用
print strtotime('next Sunday') - time();
【讨论】:
试试这个:
function secs_until() {
$now = time();
$next = strtotime("next Sunday midnight");
return $next - $now;
}
【讨论】:
很简单:
strtotime('next Sunday') - time()
【讨论】:
$seconds = mktime(0,0,0, date("n"), date("j") + (7 - date("N")), date("Y")) - time();
该字符串将在几秒钟内为您提供从现在到周日早上 12:00 的差异。您可以调整 mktime() 中的前 3 个参数,为您提供一天中的可变时间(例如上午 8:45)
【讨论】: