Copy CodeThe code is as follows:
PHP gets today's start timestamp and end timestamp
$beginToday =mktime (0,0,0,date (' m '), date (' d '), date (' Y '));
$endToday =mktime (0,0,0,date (' m '), date (' d ') +1,date (' Y '))-1;
PHP gets yesterday start timestamp and end timestamp
$beginYesterday =mktime (0,0,0,date (' m '), date (' d ') -1,date (' Y '));
$endYesterday =mktime (0,0,0,date (' m '), date (' d '), date (' Y '))-1;
PHP gets last week start timestamp and end timestamp
$beginLastweek =mktime (0,0,0,date (' m '), date (' d ')-date (' W ') +1-7,date (' Y '));
$endLastweek =mktime (23,59,59,date (' m '), date (' d ')-date (' W ') +7-7,date (' Y '));
PHP gets this month start timestamp and end timestamp
$beginThismonth =mktime (0,0,0,date (' m '), 1,date (' Y '));
$endThismonth =mktime (23,59,59,date (' m '), date (' t '), date (' Y '));
The PHP mktime () function is used to return a Unix timestamp for a date.
Grammar
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
Optional. If the time is in daylight saving time (DST), set to 1, otherwise set to 0 and if unknown, set to-1.
Since 5.1.0, the IS_DST parameter has been discarded. Therefore, you should use the new Time zone processing feature.
Usage
The parameter always represents the GMT date, so IS_DST has no effect on the result.
Parameters can be left-to-right and empty, and empty parameters will be set to the corresponding current GMT value.
Note that before PHP 5.1, if the argument for the function is illegal, it will return false.
It is also important to note that this function is useful for date arithmetic and validation. It can automatically correct out-of-bounds input, such as:
Copy the Code code as follows:
Echo (Date ("M-d-y", Mktime (0,0,0,12,36,2013)));
Output results such as: jan-05-2014
http://www.bkjia.com/PHPjc/313539.html www.bkjia.com true http://www.bkjia.com/PHPjc/313539.html techarticle Copy the code as follows://php gets the start timestamp and end timestamp for today $beginToday =mktime (0,0,0,date (' m '), date (' d '), date (' Y ')), $endToday =mktime ( 0,0,0,date (' m '), date (' d ') +1,...