A lot of very clever people have been working hard to replace Perl's confusing mish-mash of date and time modules with a consistant set of modules. The results of their labours are at http://datetime.perl.org/ and you can get all of their modules from CPAN.
Using their modules, you can solve your problem like this:
#!/usr/bin/perl use strict; use warnings; use DateTime::Format::Strptime; my $strp = DateTime::Format::Strptime->new(pattern => '%b %d %Y %I:%M% +p'); my $string = 'Dec 11 2003 12:00AM'; my $dt = $strp->parse_datetime($string) or die; $string = $dt->strftime('%m/%d/%Y'); # warning! illogical format!! print "$string\n";
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: date reformatting
by davorg
in thread date reformatting
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |