PHP Date processing-Get the start date and end date for this week and last week (memo)

Source: Internet
Author: User

Learn from:http://www.phpernote.com/php-function/1019.html

Direct Sticker Code:

1<?PHP2 Header(' content-type:text/html; Charset=utf-8 ');3 4 $date=Date(' y-m-d ');//Current Date5 6 $first= 1;//$first =1 represents a start date of Monday for every Sunday for a start date of 07 8 $w=Date(' W ',Strtotime($date));//gets the first day of the current week Sunday is 0 weeks a to Saturday is 1-69 Ten $now _start=Date(' y-m-d ',Strtotime("$date-". ($w?$w-$first: 6). ' Days ');//gets the start date of the week, if $w is 0, then represents Sunday, minus 6 days One  A $now _end=Date(' y-m-d ',Strtotime("$now _start+6 days "));//end of week date -  - $last _start=Date(' y-m-d ',Strtotime("$now _start-7 Days "));//last week start date the  - $last _end=Date(' y-m-d ',Strtotime("$now _start-1 days "));//last week end date -  - Echo' Start date of the week: ',$now _start, ' <br/> '; + Echo' This week's End date: ',$now _end, ' <br/> '; - Echo' Last week start date: ',$last _start, ' <br/> '; + Echo' Last week's End date: ',$last _end, ' <br/> '; A?>

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.