PHP mktime() Function
Definition
The mktime() function creates Unix timestamp from year, month, day, hour, second in separate variables. It has the following format.
Syntax
PHP mktime() Function has the following syntax.
int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] )
Parameter
The parameter are: hour, minute, second, month, day, year, is_dst.
Parameter | Is Required | Description |
---|---|---|
hour | Optional. | hour value |
minute | Optional. | minute value |
second | Optional. | second value |
month | Optional. | month value |
day | Optional. | day value |
year | Optional. | year value |
Return
PHP mktime() Function returns an integer Unix timestamp. FALSE on error.
Example
Note that the hour should be in 24-hour clock time. So, to pass in 10:30 p.m. on the 21th of June 2012, you would use mktime() like this:
<?PHP
$unixtime = mktime(22, 30, 0, 6, 21, 2012, -1);
print_r($unixtime);
?>
The code above generates the following result.