http://www.perlmonks.org?node_id=614228


in reply to How do I convert date format between 'DD-MM-YYYY' and 'YYYY-MM-DD' back & forth?

Just in case you specify that the date must be in US-style (MM-DD-YYYY), then the above split won't work.
my $in_date = '11-24-2007'; # or 11/24/2007, or 11.24.2007, or any non +-digit-separators my @parts = split /\D/, $in_date; my $db_date = join '-', @parts[2, 0, 1]; # to get the original format: my $sep = '-'; my @parts = split $sep, $db_date; my $pr_date = join $sep, @parts[1, 2, 0]; print "in: $in_date; db: $db_date; pr: $pr_date\n"; # in: 11-24-2007; db: 2007-11-24; pr: 11-24-2007