mktime#

Convert a broken-down local time into epoch seconds.

Synopsis#

use POSIX qw(mktime);
my $t = mktime($sec, $min, $hour, $mday, $mon, $year - 1900);

What you get back#

The epoch seconds as an integer on success. The sentinel value "0 but true" is returned when the epoch genuinely is 0 (so you can distinguish it from failure). undef is returned on failure (when the input cannot be represented).

Edge cases#

  • The tm fields are normalised in place by libc, so values outside the usual ranges (e.g. mon = 13) are accepted and carry into adjacent fields.

  • wday and yday are ignored on input; isdst defaults to -1 (let libc figure it out) when omitted.

Differences from upstream#

Fully compatible with upstream POSIX.