- // Php obtains the start timestamp and end timestamp of today.
- $ BeginToday = mktime (0, 0, 0, date ('M'), date ('D'), date ('Y '));
- $ EndToday = mktime (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 the current month.
$ BeginThismonth = mktime (0, 0, 0, date ('M'), 1, date ('Y '));
- $ EndThismonth = mktime (, 59, 59, date ('M'), date ('t'), date ('Y '));
The following describes how to use the mktime () function. The PHP mktime () function is used to return 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 in the daylight saving time (DST) period, 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. Therefore, the new time zone processing feature should be used. 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: If the parameter of this function is invalid before PHP 5.1, false is returned. Note: This function is useful for date calculation and verification. It can automatically correct out-of-range input, such as: echo (date ("M-d-Y", mktime (,); output result: jan-05-2014 Articles you may be interested in: php obtains the target function execution time instance code php obtains this week, the first day of this month and the last day of the timestamp php reference time code example php obtains the week list within a year and the instance of the weekly start time code php expires after a certain year, month, or day (not affected by the time settings of the server) code sharing php date and time computing instance sharing php display by time just a few minutes ago, a few hours ago implementation code php time format validation function example calculated php time difference how many days, how many hours of code php get the timestamp of a certain time interval code php get the system time code example php get the simple method of program execution time php get the server time related php call time detailed description of format parameters PHP regular expression matching date and time (timestamp conversion) example php get time and day of the week php timestamp function summary and example php current time, timestamp acquisition method summary php timestamp function strtotime application instance calculate two timestamps separated time functions (php and js) php timestamp application example php get timestamp for a certain time range and regularly send mail code php time conversion Unix timestamp code show today, this month, last month, this year's start and end and timestamp code php several ways to get time php get current date and time details learning php time stamp and date format conversion |