Php obtains the processing of calendar week and calendar month.

Source: Internet
Author: User
If the current date is Tuesday 20160614, the last week's time interval is 20160606-20160612, and the current date is not completed (that is, this week is not completed on Sunday) so last week will always be [20160606]-[20160612]. how can php obtain the current date of the last week's time range? [2016/06/14 Tuesday]

Then the last week's time range is]

Only the current date is not completed (that is, this week is not completed)

So last week we will always be]

How does php obtain the last week's time range?

Reply content:

The current date is [2016/06/14 Tuesday]

Then the last week's time range is]

Only the current date is not completed (that is, this week is not completed)

So last week we will always be]

How does php obtain the last week's time range?

Use strtotime. check the manual for details. Exampledate('Y-m-d', strtotime('-1 week'))Obtain the week before the current time, and the month is alsodate('Y-m-d', strtotime('-1 month')), Day or year.

echo date("Y-m-d",strtotime('-1 week last monday'))." 00:00:00";
echo date("Y-m-d",strtotime('last sunday'))." 23:59:59";

Echo'
Last week start time:
'; Echo date ("Y-m-d H: I: s", mktime (0, 0, 0, date ("m"), date ("d ") -date ("w") + 1-7, date ("Y"), "\ n"; echo date ("Y-m-d H: I: s ", mktime (23,59, 59, date (" m "), date (" d ")-date (" w ") + 7-7, date ("Y"), "\ n ";

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.