Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Answer: How do I convert date format between 'DD-MM-YYYY' and 'YYYY-MM-DD' back & forth?

( #614227=categorized answer: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $in_date = '30-04-2007';
    my $db_date = join '-', reverse split '-', $in_date;
    ...
    my $pr_date = join '-', reverse split '-', $db_date;
    print "in: $in_date; db: $db_date; pr: $pr_date\n";
    # in: 30-04-2007; db: 2007-04-30; pr: 30-04-2007
    
  2. or download this
    my $in_date = '02/05/2007'; # or 02.05.2007, or any non-digit-separato
    +rs
    my $db_date = join '-', reverse split /\D/, $in_date;
    ...
    my $pr_date = join $sep, reverse split '-', $db_date;
    print "in: $in_date; db: $db_date; pr: $pr_date\n";
    # in: 02/05/2007; db: 2007-05-02; pr: 02-05-2007
    

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2014-08-21 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (127 votes), past polls