Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP mktime() Function

PHP mktime() Function

PHP Date/Time PHP Date/Time Reference Manual

Example

Return the UNIX timestamp of a date, then use it to find the day of that date:

Run Example »


Definition and Usage

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

**Tip:** The difference between this function and gmmktime() Same as gmmktime(), except that the passed parameters represent a date (not a GMT date).

Syntax

mktime(

hour,minute,second,month,day,year,is_dst

);

Parameters 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 figure it out itself (which may produce unexpected results). **Note:** This parameter was deprecated in PHP 5.1.0; use the new time zone handling features instead.

Technical Details

Return Value: Returns an integer Unix timestamp, or FALSE on error.
PHP Version: 4+
Changelog: PHP 5.3.0: If the is_dst parameter is used, an E_DEPRECATED is raised.
PHP 5.1.0:is_dst This parameter was deprecated. If mktime() is called without arguments, an E_STRICT notice is raised. Use the time() function instead.

PHP Date/Time PHP Date/Time Reference Manual