document updated 1 year, 9 months ago, on Feb 14, 2023
"Broken-down time" means the typical array ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst), and it correlates to the C standard library's struct tm.
Core modules
- core functions
- gmtime — converts a Unix/epoch time into broken-down time (or, in scalar context, to a string)
- localtime — converts a Unix/epoch time into broken-down time (or, in scalar context, to a string)
- time — gets the current Unix/epoch time
- times — gets four current and cummulative times
- Time::Local — does the opposite of 'localtime' and 'gmtime', converts a broken-down time into a Unix/epoch time
- Time::Seconds — converts a seconds-based-interval into an equivalent interval of days, hours, months, etc. Probably often used in conjunction with Unix/epoch time-based times.
- Time::HiRes — high-resolution time routines
- Time::Piece — a core-module alternative to things like 'DateTime', 'Date::Manip', and 'Date::Simple'
- POSIX
Important modules
Parsing
- high-level
- medium-level
- low-level
If you're stuck using low-level parsing libraries, here is some useful information for writing custom date parsers.
Timezones
To change your script's local timezone at the top of the script:
use POSIX;
$ENV{TZ} = 'CST6CDT';
POSIX::tzset();
Formatting
- strftime() is the quintessential function here, and can be found in various places:
- rounding to English expressions (eg. "6 seconds ago", "4 days ago")