Hi,
I need convert a date string to date.
For eaxmple
$last_date=6/2/2009
and I want to change the format of the above mentioned date to "Jun 2 2009 12:00AM".
Do we have any functionality or staright method to convert to the desired format?
Hi,
I need convert a date string to date.
For eaxmple
$last_date=6/2/2009
and I want to change the format of the above mentioned date to "Jun 2 2009 12:00AM".
Do we have any functionality or staright method to convert to the desired format?
perl '-MPOSIX qw(strftime)' -le'
$last_date = "6/2/2009";
@dt = split /\//, $last_date;
print strftime( "%B %d %Y %I:%M%p", 0, 0, 0, $dt[1], $dt[0] - 1,
$dt[2] - 1900 );
'
There is also ParseDate from Date::Manip.
Great. It works. Thanks a lot. Can you please describe bit elaborately? I donot understand logic.
Following is the very simple thing to do ...
use Date::Manip;
print ParseDate("6/3/2009");
@dt = split /\//, $last_date; # build an array that contains the date elements:
# + $dt[0] contains the month ... $dt[2] - the year.
print strftime( "%B %d %Y %I:%M%p", 0, 0, 0, $dt[1], $dt[0] - 1,
$dt[2] - 1900 ); # the month begin at zero, the year is given in years
# + since 1900, see perldoc POSIX | less -pstrftime
# + for more information.