Tuesday, November 4, 2008

Perl and Dates

Just a quick code snippet I through together to remember some of the date parsing modules that seem to come standard with Perl 5:

use Date::Parse;
use Date::Format;
use strict;

my $date = "2008-12-30 05:00:00";
my $machine_time = str2time($date);
my $week = time2str("%U", $machine_time);
my $month = time2str("%L", $machine_time);

print < < EOF;

Date is: $date
Machine Time is: $machine_time
Week is: $week
Month is: $month

EOF

No comments: