: 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.