php获取本周开始日期和结束日期的方法,php开始日期_PHP教程

WBOY
Release: 2016-07-13 10:04:31
Original
1231 people have browsed it

php获取本周开始日期和结束日期的方法,php开始日期

本文实例讲述了php获取本周开始日期和结束日期的方法。分享给大家供大家参考。具体如下:
复制代码代码如下://当前日期
$sdefaultDate = date("Y-m-d");
//$first =1 表示每周星期一为开始日期 0表示每周日为开始日期
$first=1;
//获取当前周的第几天 周日是 0 周一到周六是 1 - 6
$w=date('w',strtotime($sdefaultDate));
//获取本周开始日期,如果$w是0,则表示周日,减去 6 天
$week_start=date('Y-m-d',strtotime("$sdefaultDate -".($w ? $w - $first : 6).' days'));
//本周结束日期
$week_end=date('Y-m-d',strtotime("$week_start +6 days"));

希望本文所述对大家的php程序设计有所帮助。

www.bkjia.com true http://www.bkjia.com/PHPjc/965351.html TechArticle php获取本周开始日期和结束日期的方法,php开始日期 本文实例讲述了php获取本周开始日期和结束日期的方法。分享给大家供大家参考。具体...
Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!