Php displays various time periods

Source: Internet
Author: User
: This article mainly introduces various time periods for php display. For more information about PHP tutorials, see. Zookeeper

Set the time to Beijing time first.

Date_default_timezone_set ('prc ');

Current time
$ Curtime = date ("Y-m-d H: I: s", time ());

The division on Monday is different from what we usually understand, so we need to judge separately.

If (date ('D') = 'mon '){

Last week:

$ Last_week_start = date ("Y-m-d H: I: s", strtotime ("last Monday "));
$ Last_week_end = date ("Y-m-d H: I: s", strtotime ("this Monday "));

This week:
$ This_week_start = date ("Y-m-d H: I: s", strtotime ("this Monday "));
$ This_week_end = date ("Y-m-d H: I: s", strtotime ("next Monday "));


} Else {

Last week:
$ Last_week_start = date ("Y-m-d H: I: s", strtotime ("last Monday-1 week "));
$ Last_week_end = date ("Y-m-d H: I: s", strtotime ("this Monday-1 week "));

This week:
$ This_week_start = date ("Y-m-d H: I: s", strtotime ("this Monday-1 week "));
$ This_week_end = date ("Y-m-d H: I: s", strtotime ("next Monday "));
}

Last month:
$ Last_m Month ")."-01 00:00:00 ";
$ Last_m Month ")."-01 00:00:00 ";
This month:
$ This_m Month ")."-01 00:00:00 ";
$ This_m Month ")."-01 00:00:00 ";
Day:
$ This_day_start = date ("Y-m-d", time (). "00:00:00 ";
$ This_day_end = date ("Y-m-d", strtotime ("+ 1 day"). "00:00:00 ";

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above introduces various time periods for php display, including some content, and hope to help those who are interested in PHP tutorials.

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.