mktime
Builds a timestamp from separate parts of a date.
Syntax
mktime(int $hour, ?int $minute = null, ?int $second = null, ?int $month = null, ?int $day = null, ?int $year = null): int|falseParameters
| Parameter | Type | Description |
|---|---|---|
| $hour | int | The hours. |
| $minute | ?int | The minutes. |
| $second | ?int | The seconds. |
| $month | ?int | The month. |
| $day | ?int | The day. |
| $year | ?int | The year. |
Return value
int|falseA timestamp.
Examples
A date from its parts:
<?php
echo date('d.m.Y H:i', mktime(14, 5, 0, 1, 30, 2025));Output:
30.01.2025 14:05Extra days roll over into the next month:
<?php
echo date('d.m.Y', mktime(0, 0, 0, 1, 32, 2025));Output:
01.02.2025Notes
The argument order is unusual: the time first, then the month, the day and the year.
See also
Related recipes
In the tutorial
- Date and time — Working with dates in PHP — the date function, the DateTimeImmutable class, formats, adding to dates and the difference between them.