PHPmktime () function definition and usage
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 |
Optional. The specified hour. |
| Minute |
Optional. Minutes. |
| Second |
Optional. Specified seconds. |
| Month |
Optional. Indicates the month in number. |
| Day |
Optional. Specified day. |
| Year |
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 |
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. |
Tips and comments
Note: Before PHP 5.1, if the parameter of this function is invalid, false is returned.
Example
The mktime () function is very useful for date calculation and verification. It can automatically correct out-of-range input:
Output:
Jan-05-2002Feb-01-2002Jan-01-2001Jan-01-1999