For example, php obtained last week, this week, last month, this month, this quarter, and the last quarter.
- Date_default_timezone_set ('prc ');
- Date ("Y-m-d H: I: s", strtotime ("+ 2 year "));
- Date ("Y-m-d H: I: s", strtotime ("+ 2 month "));
- Date ("Y-m-d H: I: s", strtotime ("+ 2 week "));
- Date ("Y-m-d H: I: s", strtotime ("+ 2 day "));
- Date ("Y-m-d H: I: s", strtotime ("+ 2 hour "));
- Date ("Y-m-d H: I: s", strtotime ("+ 2 minute "));
- Date ("Y-m-d H: I: s", strtotime ("+ 2 second "));
-
- Echo date ("Ymd", strtotime ("now"), "\ n ";
- Echo date ("Ymd", strtotime ("-1 week Monday"), "\ n ";
- Echo date ("Ymd", strtotime ("-1 week Sunday"), "\ n ";
- Echo date ("Ymd", strtotime ("+ 0 week Monday"), "\ n ";
- Echo date ("Ymd", strtotime ("+ 0 week Sunday"), "\ n ";
-
- Echo "********** months :";
- Echo date ('N ');
- Echo "********** week :";
- Echo date ("w ");
- Echo "********** number of days this month :";
- Echo date ("t ");
- Echo "*********";
-
- Echo'
Last week: ';
- 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 ";
- Echo'
This week: ';
- Echo date ("Y-m-d H: I: s", mktime (0, 0, 0, date ("m"), date ("d ") -date ("w") + 1, date ("Y"), "\ n ";
- Echo date ("Y-m-d H: I: s", mktime (23, 59, 59, date ("m"), date ("d ") -date ("w") + 7, date ("Y"), "\ n ";
-
- Echo'
Last month: ';
- Echo date ("Y-m-d H: I: s", mktime (0, 0, 0, date ("m")-1,1, date ("Y"), "\ n ";
- Echo date ("Y-m-d H: I: s", mktime (23, 59, 59, date ("m"), 0, date ("Y "))), "\ n ";
- Echo'
This month: ';
- Echo date ("Y-m-d H: I: s", mktime (0, 0, 0, date ("m"), 1, date ("Y"), "\ n ";
- Echo date ("Y-m-d H: I: s", mktime (23, 59, 59, date ("m"), date ("t "), date ("Y"), "\ n ";
-
- $ Season = ceil (date ('N')/3); // The quarter of the current month
-
- Echo'
This quarter: ';
- Echo date ('Y-m-d H: I: S', mktime (0, 0, 0, $ season * 3-3 + 1,1, date ('Y'), "\ n ";
- Echo date ('Y-m-d H: I: S', mktime (, 59, $ season * 3, date ('t', mktime (0, 0, 0, $ season * 3, 1, date ("Y"), date ('Y'), "\ n ";
-
- $ Season = ceil (date ('N')/3)-1; // the first quarter of the last quarter
-
- Echo'
Last quarter: ';
- Echo date ('Y-m-d H: I: S', mktime (0, 0, 0, $ season * 3-3 + 1,1, date ('Y'), "\ n ";
- Echo date ('Y-m-d H: I: S', mktime (, 59, $ season * 3, date ('t', mktime (0, 0, 0, $ season * 3, 1, date ("Y"), date ('Y'), "\ n ";
- ?>
|