Home  >  Article  >  php教程  >  Calculate the year, month and day of this week's Sunday based on the time of the day

Calculate the year, month and day of this week's Sunday based on the time of the day

大家讲道理
大家讲道理Original
2016-11-09 10:10:00915browse

<?php
//计算本周的星期天是什么日期
date_default_timezone_set("Asia/Shanghai");
header(&#39;content-Type: text/html; charset=utf-8&#39;);
//今天星期几
$today_xq = date(&#39;w&#39;);
//离星期天几天
$sunday = 7 - $today_xq;
 
//计算出本周星期天的日期
$date = date("Y-m-d",time()+$sunday*3600*24);
 
echo &#39;本周星期天是:&#39;.$date;
 
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn