PHP gets the first and last day of the current week

Source: Internet
Author: User
Current date $sdefaultDate = Date ("y-m-d");  $first =1 represents a starting date of Monday per week for 0, which is the start date of each Sunday $first = 1;  Gets the day ordinal of the current week Sunday is 0 weeks a to Saturday is 1-6 echo $w = Date (' W ', Strtotime ($sdefaultDate)); Gets the start date of the week, if $w is 0, then represents Sunday, minus 6 days for echo $week _start = Date (' y-m-d ', Strtotime ("$sdefaultDate-". ($w? $w-$first: 6).  ' days ')); This week's end date echo $week _end = Date (' y-m-d ', Strtotime ("$week _start +6 Days");


This article from "for the Future" blog, declined reprint!

PHP gets the first and last day of the current week

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.