Programming Perl

Programming PerlSearch this book
Previous: 7.2.74 Tie::SubstrHash - Fixed-table-size, Fixed-key-length HashingChapter 7
The Standard Perl Library
Next: 7.2.76 vars - Predeclare Global Variable Names
 

7.2.75 Time::Local - Efficiently Compute Time from Local and GMT Time

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.


Previous: 7.2.74 Tie::SubstrHash - Fixed-table-size, Fixed-key-length HashingProgramming PerlNext: 7.2.76 vars - Predeclare Global Variable Names
7.2.74 Tie::SubstrHash - Fixed-table-size, Fixed-key-length HashingBook Index7.2.76 vars - Predeclare Global Variable Names



Banner.Novgorod.Ru