Monday, October 13, 2008

Perl: Date formatting

If you need to convert Date from YYYY-MM-DD format to MM/DD/YYYY format, use below perl code.

$str="2008-10-13";
$str =~s/^(\d{4})\-(\d{2})\-(\d{2})/$2\/$3\/$1/;
print $str;

will output:
10/13/2008

No comments: