use Time::Local; $time = timelocal($sec, $min, $hours, $mday, $mon, $year); $time = timegm($sec, $min, $hours, $mday, $mon, $year);
These routines take a series of arguments specifying a local
(timelocal()
) or Greenwich (timegm()
) time, and return the
number of seconds elapsed between January 1, 1970, and the specified time.
The arguments are defined like the corresponding arguments returned by
Perl's gmtime and localtime functions.
The routines are very efficient and yet are always guaranteed to agree
with the gmtime and localtime functions. That is,
if you pass the value returned by time to localtime, and if
you then pass the values returned by localtime to
timelocal()
, the returned value from timelocal()
will be
the same as the value originally returned from time.
Both routines return -1
if the integer limit is hit. On most
machines this applies to dates after January 1, 2038.