PHP gets the start timestamp and end timestamp of today, yesterday, last week, this month, mainly using PHP's time function mktime ().
The Mktime function uses the following: Mktime (HOUR,MINUTE,SECOND,MONTH,DAY,YEAR,IS_DST)
Parameter description
Hour is optional. Specified hours.
Minute is optional. Specify minutes.
Second is optional. Specify seconds.
Month is optional. Specifies the number of months to be represented.
Day is optional. Prescribed days.
Year is optional. Prescribed year. On some systems, the legal value is between 1901-2038. However, there is no such limit in PHP 5.
IS_DST is optional. If the time is in daylight saving time (DST), set to 1, otherwise set to 0 and if unknown, set to-1. (since PHP 5.1.0, this parameter has been deprecated.) The new Time zone processing feature should be used instead. )
Example: Start timestamp and end timestamp for today, yesterday, last week, this month
1 //get today start timestamp and end timestamp2 $start=Mktime(0,0,0,Date(' m '),Date(' d '),Date(' Y '));3 $end=Mktime(0,0,0,Date(' m '),Date(' d ') +1,Date(' Y ')) -1;4 //get yesterday start timestamp and end timestamp5 $beginYesterday=Mktime(0,0,0,Date(' m '),Date(' d ')-1,Date(' Y '));6 $endYesterday=Mktime(0,0,0,Date(' m '),Date(' d '),Date(' Y ')) -1;7 //get last week start timestamp and end timestamp8 $beginLastweek=Mktime(0,0,0,Date(' m '),Date(' d ')-Date(' W ') +1-7,Date(' Y '));9 $endLastweek=Mktime(23,59,59,Date(' m '),Date(' d ')-Date(' W ') +7-7,Date(' Y '));Ten //get this month start timestamp and end timestamp One $beginThismonth=Mktime(0,0,0,Date(' m '), 1,Date(' Y ')); A $endThismonth=Mktime(23,59,59,Date(' m '),Date(' t '),Date(' Y '));
PHP mktime function gets today's start and end timestamp