- Perl ›
- Date/Time
Handle date/time in Perl
The handling of "date/time" in Perl is summarized.
If Perl 5.10 or later is installed, the standard module Time::Piece that handles date and time is attached as standard. We recommend that you try this first.
If you want to handle dates more strictly than Time::Piece, you can install the DataTime module from cpan.
When it comes to large-scale processing, date/time processing may become a bottleneck. In such cases, you can also use the high-performance Time::Moment module.
Builtin functions for handling date/time
- Get the number of seconds elapsed from the epoch to the present time - time function
- Get the current date and time(local time) - localtime function
- Get the current date and time(Coordinated Universal Time) - gmtime function
- Convert date and time(local time) to epoch seconds -Time::Local::timelocal ()
- Convert date and time(Coordinated Universal Time) to epoch seconds -Time::Local::timegm ()
Special date
- Get a list of holidays (Google Calendar Data API)
- Determine if it is a leap year
- Determine if it exists
- Get the last day of the month