Pages

Monday, April 11, 2011

Date Formats in Perl

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

my $date =$item->{link};
my $formattedDate = str2time($date );
$formattedDate = time2str('%m/%d/%Y', $formattedDate);
print $formattedDate;

or

$formattedDate = time2str('%m-%d-%Y', $formattedDate);
print $formattedDate;

or

$formattedDate = time2str('%m-%d-%Y_%H-%M-%S_', $formattedDate);
print $formattedDate;