Name

localtime

Synopsis

$lt = localtime(  )

Overrides the core localtime function. The Time::tm object returned has methods with the same names as the structure fields they return. That is, to return the field mon, use the mon method:

use Time::localtime;
$lt = localtime(  );
print $lt->mon;

The field names (and therefore the method names) are the same as the names of the fields in the tm structure in the C file time.h: sec, min, hour, mday, mon, year, wday, yday, and isdst. You can access the fields with the methods or by importing the fields into your namespace with the :FIELDS import tag and prepending tm_ to the method name (for example, $tm_mon).

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.