Php obtains the start and end timestamps of today, yesterday, last week, and this month.

Source: Internet
Author: User
Php obtains the start timestamp and end timestamp of today, yesterday, last week, and this month. php obtains the start timestamp and end timestamp of today, yesterday, last week, and this month, it mainly uses the php time function mktime. Next, let's go straight to the topic to illustrate how to use mktime to obtain the start and end timestamps of today, yesterday, last week, and this month, next, let's introduce how php obtains the start and end timestamps of today, yesterday, last week, and this month.
Php mainly uses the php time function mktime to obtain the start timestamp and end timestamp of today, yesterday, last week, and this month. Next we will go straight to the topic to illustrate how to use mktime to obtain the start and end timestamps of today, yesterday, last week, and this month. then we will introduce the functions and usage of the mktime function .? // Obtain the start and end timestamps of today in php? $ 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 obtains the start timestamp and end timestamp of yesterday? $ 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 obtains the 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 obtains the start timestamp and end timestamp of this month? $ BeginThismonth = mktime (0, 0, 0, date ('M'), 1, date ('Y '));? $ EndThismonth = mktime (, 59, 59, date ('M'), date ('t'), date ('Y'); PHP mktime () returns the Unix timestamp of a date .? Syntax? Mktime (hour, minute, second, month, day, year, is_dst )? Parameter description hour is optional. The specified hour. Minute is optional. Minutes. Second is optional. Specified seconds. Month is optional. Indicates the month in number. Day is optional. Specified day. Year is optional. Specified year. In some systems, the valid value ranges from 1901 to 2038. However, this restriction does not exist in PHP 5. Is_dst is optional. If the time is during daylight saving time (DST), it is set to 1; otherwise, it is set to 0. if it is unknown, it is set to-1 .? The is_dst parameter has been deprecated since 5.1.0. So we 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 .? The parameters can be left empty from right to left. the blank parameters are set to the corresponding current GMT value .? Note that, before PHP 5.1, if the parameter of this function is invalid, false is returned .? Note that this function is useful for date calculation and verification. It can automatically correct out-of-range input, such :?? Echo (date ("M-d-Y", mktime )));? The output result is: php100.com? Source: http://www.php100.com/html/webkaifa/PHP/PHP/2013/0711/13642.html

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.