How about:
use HTTP::Date qw( time2iso str2time ); my $original = '20100302165019'; my ($year, $month, $day) = $original =~ m{^(\d{4})(\d{2})(\d{2})}; my $time = str2time("$year\-$month\-$day"); my $localtime = localtime( $time ); my $isodate = time2iso($time); print "Localtime: '$localtime'\n"; print "ISO Date: '$isodate'\n";
Your output would be:
Localtime: 'Tue Mar 2 00:00:00 2010' ISO Date: '2010-03-02 00:00:00'
In reply to Re: Date conversion in perl?
by jdrago999
in thread Date conversion in perl?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |