Home

mktime

mktime is a commonly used function name in programming libraries for converting a broken-down time into a numeric timestamp. In the C standard library, the function prototype is time_t mktime(struct tm *tm); In PHP, mktime(hour, minute, second, month, day, year, is_dst) returns a Unix timestamp for a date in the local timezone.

In the C form, the function accepts a pointer to a struct tm that contains fields for

In PHP, mktime constructs a timestamp based on the provided date and time components in the server's

tm_sec,
tm_min,
tm_hour,
tm_mday,
tm_mon,
tm_year,
and
auxiliary
fields
tm_wday,
tm_yday,
tm_isdst.
mktime
normalizes
fields
that
are
out
of
range,
adjusting
the
date
and
time
as
needed.
It
also
fills
in
tm_wday
and
tm_yday
and
returns
the
corresponding
time_t
value
that
represents
the
local
time.
The
operation
is
influenced
by
the
process's
time
zone
and
DST
settings;
if
the
given
time
cannot
be
represented,
or
if
the
normalization
fails,
mktime
returns
(time_t)
-1.
local
timezone.
All
parameters
are
optional
and
default
to
the
current
local
time
when
omitted.
The
final
parameter
is_dst
can
be
used
to
force
daylight
saving
time
handling
or
set
to
-1
to
have
PHP
determine
DST
automatically.
The
function
returns
an
integer
timestamp
on
success,
or
false
on
failure.
The
PHP
equivalent
in
UTC
is
gmmktime.