Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Format user entered date?

by astroboy (Chaplain)
on Sep 01, 2009 at 00:40 UTC ( #792501=note: print w/replies, xml ) Need Help??


in reply to Format user entered date?

#!/usr/local/bin/perl use DateTime::Format::Natural; my @dates = ('Yesterday', '21st August 2009', '2009-07-17 2:35pm'); my $output_format = '%d/%m/%Y %H:%M:%S'; foreach my $date (@dates) { my $parser = DateTime::Format::Natural->new; my $dt = $parser->parse_datetime($date); print $dt->strftime($output_format), "\n";; }
Output
31/08/2009 00:00:00 21/08/2009 00:00:00 17/07/2009 14:35:00

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://792501]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2016-10-01 19:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (6 votes). Check out past polls.