PHP gets today, yesterday, last week, this month's start time stamp and end time stamp method, mainly uses in the PHP time function mktime. Let's start with an example of how to use Mktime to get the start time stamp and end time stamp for today, yesterday, last week, month, and then introduce the function and usage of mktime functions. //php get 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 get yesterday's start time stamp 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 get last week's 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 get the 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 optional. Set hours. Minute optional. Specify minutes. Second Optional. Specified seconds. Month optional. A month that is specified in numbers. Day is optional. Stipulated day. YeAr Optional. Set year. On some systems, the legal value is between 1901-2038. However, there is no such limit in PHP 5. Is_dst Optional. If time is in daylight saving time (DST), set to 1, otherwise set to 0, if unknown, set to-1. since 5.1.0, IS_DST parameters have been discarded. Therefore, you should use the new time zone processing attributes. Usage parameters always represent GMT dates, so IS_DST has no effect on the results. The parameters can be left-to-right, and the empty arguments will be set to the appropriate current GMT value. Note that before PHP 5.1, if the parameter of the function is illegal, it returns false. It is also important to note that the function is useful for date operations and validation. It automatically corrects for cross-border input such as: echo (Date ("M-d-y", Mktime (0,0,0,12,36,2001)); will output results such as: php100.com
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.