Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1397
  • Last Modified:

Perl, convert date string from format mm/dd/yyyy (12/15/2010) to yyyy-mm-dd (2010-12-15)

Perl,

How do I convert date string from format mm/dd/yyyy (12/15/2010) to yyyy-mm-dd (2010-12-15) using any of the Perl "date" library.  Because using the Perl "date", the date can be checked for validity.

0
rgbcof
Asked:
rgbcof
  • 2
3 Solutions
 
ozoCommented:
s#(\d+)/(\d+)/(\d+)#$3-$1-$2#
or
join'-',(split/\D/)[2,0,1];
0
 
rockiroadsCommented:
could u make use of strtotime?
something along these lines


      $newDate = date("Y-m-d", strtotime($dt));


where $dt is your original date
0
 
rockiroadsCommented:
u could possibly use mktime as well to create a date, not as good though
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now