PHP mktime()Function

PHP Date/TimePHP Date/Time Reference Manual

Examples

Returns the UNIX timestamp of a date, then uses it to find the day of that 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));
?>

Run example »

Definition and Usage

The mktime() function returns the UNIX timestamp of a date.

Tip:This function is the same asgmmktime()except that the parameters passed represent a date (not a GMT date).

Syntax

mktime(hour,minute,second,month,day,year,is_dst);

Parameter Description
hour Optional. Specifies the hour.
minute Optional. Specifies the minute.
second Optional. Specifies the second.
month Optional. Specifies the month.
day Optional. Specifies the day.
year Optional. Specifies the year.
is_dst Optional. Set to 1 if the time is during daylight saving time, 0 otherwise, or -1 (default) if unknown. If unknown, PHP tries to find it itself (which may produce unexpected results).Note:This parameter was deprecated in PHP 5.1.0. Instead, use the new timezone handling features.

Technical Details

Return value: Returns an integer Unix timestamp, or FALSE on error.
PHP version: 4+
Changelog: PHP 5.3.0: If theis_dstparameter is used, an E_DEPRECATED is thrown.
PHP 5.1.0:is_dstThe parameter is deprecated. If mktime() is called without any parameters, an E_STRICT notice is thrown. Please use the time() function instead.


PHP Date/TimePHP Date/Time Reference Manual Other Extensions