从现在()到星期日午夜的秒数

fre*_*est 4 php time

在PHP中,如何获得从now()下午星期六到午夜的秒数?

我不希望解决方案相对于特定日期,而只是到下一个星期日.

Vin*_*nto 18

$seconds = strtotime('next Sunday') - time();
Run Code Online (Sandbox Code Playgroud)


Mat*_*den 7

您可以使用

print strtotime('next Sunday') - time();
Run Code Online (Sandbox Code Playgroud)


fir*_*ire 5

试试这个:

function secs_until() {
  $now = time();
  $next = strtotime("next Sunday midnight");
  return $next - $now;
}
Run Code Online (Sandbox Code Playgroud)