Util::Medley::DateTime - Class with various datetime methods.
version 0.024
my $dt = Util::Medley::DateTime->new; # # positional # say $dt->localDateTime(time); # # named pair # say $dt->localDateTime(epoch => time);
A small datetime library. This doesn't do any calculations itself, but provides some simple methods to call for getting the date/time in commonly used formats.
none
Returns the local-date-time in the format: YYYY-MM-DD HH:MM:SS.
$dt->localDateTime([time]); $dt->localDateTime([epoch => time]);
Epoch time used to generate date/time string. Default is now.
Adds days, hours, mins, and/or secs to a local-date-time string.
$newDateTime = $dt->localDateTimeAdd($dateTime, [0, 1, 0, 0]); $newDateTime = $dt->localDateTimeAdd( dateTime => $dateTime, [days => 0], [hours => 1], [mins => 0], [secs => 0]);
A local-date-time string.
Days to add.
Hours to add.
Minutes to add.
Seconds to add.
Converts a local-date-time string to epoch.
$epoch = $dt->localDateTimeToEpoch($dateTime); $epoch = $dt->localDateTimeToEpoch(dateTime => $dateTime);
The local-date-time string to convert.
Validates the date-time string against: YYYY-MM-DD HH:MM:SS. Also, checks if it is actually a valid date-time.
$dt->localDateTimeIsValid($dateTime); $dt->localDateTime(dateTime => $dateTime);
The date-time string to validate.
To install Util::Medley, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Util::Medley
CPAN shell
perl -MCPAN -e shell install Util::Medley
For more information on module installation, please visit the detailed CPAN module installation guide.