Solved

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

Posted on 2010-09-11
3
991 Views
Last Modified: 2012-05-10
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
Comment
Question by:rgbcof
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 84 total points
Comment Utility
s#(\d+)/(\d+)/(\d+)#$3-$1-$2#
or
join'-',(split/\D/)[2,0,1];
0
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 166 total points
Comment Utility
could u make use of strtotime?
something along these lines


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


where $dt is your original date
0
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 166 total points
Comment Utility
u could possibly use mktime as well to create a date, not as good though
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now