PHP mktime () function
PHP Date / Time Reference Manual
Examples
Returns the UNIX timestamp for a date, and then use it to find the day of the date:
<?php
// Prints: October 3, 1975 was on a Friday
echo "Oct 3, 1975 was on a ".date("l", mktime(0,0,0,10,3,1975));
?>
// Prints: October 3, 1975 was on a Friday
echo "Oct 3, 1975 was on a ".date("l", mktime(0,0,0,10,3,1975));
?>
Running instance »
Definition and Usage
gmmktime () function returns the UNIX timestamp for a date.
Tip: This function gmmktime () the same, except that the passed parameter represents a date (the date is not GMT).
grammar
mktime( hour,minute,second,month,day,year,is_dst );
参数 | 描述 |
---|---|
hour | 可选。规定小时。 |
minute | 可选。规定分。 |
second | 可选。规定秒。 |
month | 可选。规定月。 |
day | 可选。规定天。 |
year | 可选。规定年。 |
is_dst | 可选。如果时间在夏令时期间,则设置为 1,否则设置为 0,若未知则设置为 -1(默认)。如果未知,PHP 会试图找到自己(可能产生意外的结果)。 注意:该参数在 PHP 5.1.0 中被废弃。取而代之使用的是新的时区处理特性。 |
technical details
return value: | It returns an integer Unix timestamp, if an error is returned FALSE. |
---|---|
PHP version: | 4+ |
Update log: | PHP 5.3.0: If is_dst parameter is thrown E_DEPRECATED. PHP 5.1.0: is_dst parameters are discarded. If mktime () is called with no parameters, throws E_STRICT notice. Please use the time () function substitute. |
PHP Date / Time Reference Manual