PHP uses mktime () to obtain the timestamp of a certain time range. This article introduces how to obtain the timestamp of a certain time range in PHP, mainly by using time and mktime. if you need it, you can check it out. the code is as follows: Copy the code $ ydate (Y This article describes how to obtain the timestamp of a certain time range in PHP, mainly using time and mktime for operations, if you need it, you can check it out.
| The code is as follows: |
|
|
$ Y = date ("Y", time ());
$ M = date ("m", time ());
$ D = date ("d", time ());
$ Start_time = mktime (9, 0, 0, $ m, $ d, $ y );
$ End_time = mktime (19, 0, 0, $ m, $ d, $ y );
$ Time = time ();
If ($ time >=$ start_time & $ time <= $ end_time)
{
// Do something ....
} |
There is a place above. we can change it.
| The code is as follows: |
|
| $ Start_time = mktime (9, 0, 0, date ("m"), date ("d"), date ("Y ")); |
Mktime function introduction
The mktime () function returns the Unix timestamp of a date.
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.
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.
The timestamp of the period interval is mainly used for time and mktime operations. if you need it, you can check it. the code is as follows: $ y = date (Y...