Number of seconds from now() to Sunday midnight

后端 未结 5 1857
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-13 18:11

In PHP how do I get the number of seconds from now() until the next Sunday at midnight?

I don\'t want the solution relative to a specific date, but just

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-13 18:27

    Try this:

    function secs_until() {
      $now = time();
      $next = strtotime("next Sunday midnight");
      return $next - $now;
    }
    

提交回复
热议问题