Visit the Official PHP Website

Search this Site

PHP Programming

By James N Hitz

The mktime() function

The mktime() function is a PHP function that returns the Unix time calculated from the arguments given. This time is an integer containing the number of seconds between the Unix Epoch (January 1 1970) and the time specified.

The function expects you to supply it with the hour, minute, seconds, month, day, year IN THAT ORDER. In return it gives the number of seconds that have elapsed since

The Arguments passed to the mktime() function may be left out in order from right to left; any arguments thus omitted will be set to the current value according to the local date and time. To use this function:

$secondsSinceEpoch = mktime(hour, minute, second, month, day, year);

The year may be a two or four digit value, with values between 0-69 translating to 2000-2069 and 70-99 to 1970-1999 depending on the computer the valid date may be set to a value upto 2037.

The last day of any given month can be expressed as the "0" day of the next month, not the -1 day.

mktime() is most of the time used along with the date() function (discused below) to perform date arithmetic.

<< The time() function | The date() function >>

JamHitz Productions