home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book Home Programming PerlSearch this book

32.45. Time::localtime

use Time::localtime;
printf "Year is %d\n", localtime->year() + 1900;

$now = ctime();

use Time::localtime;
use File::stat;
$date_string = ctime(stat($file)->mtime);
This module's overrides the core localtime function, replacing it with a version that returns a Time::tm object (or undef on failure). The Time::gmtime module does the same thing, except it replaces the core gmtime function, instead. The returned object has methods that access the like-named structure field names from the C library's struct tm out of time.h; namely sec, min, hour, mday, mon, year, wday, yday, and isdst. The ctime function provides a way of getting at (the scalar sense of) the original CORE::localtime function. Note that the values returned are straight out of a struct tm, so they have the same ranges found there; see the example above for the correct way to produce a four-digit year. The POSIX::strftime function is even more useful for formatting dates and times in a variety of appealing styles.



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.











??????????????@Mail.ru