Perl, create a perl date object with date string of several formats

I would like to create a perl date object with date string of several formats like 2/2/10, 02/02/10, where field is (month/day/year).

 
rgbcofAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ozoConnect With a Mentor Commented:
POSIX::strftime can convert a time_t into any of several formats.
Date::Manip can do pretty much any date/time operation you could ever want.
0
 
Brad HoweConnect With a Mentor DevOps ManagerCommented:
Why not just use the Date::format function?
http://datetime.perl.org/?Modules 
http://search.cpan.org/~gbarr/TimeDate-1.20/lib/Date/Format.pm 
#!/usr/bin/perl
use date::format;

print time2str("%D", time), "\n";
# (prints 09/09/10)

print time2str("%m/%d/%Y", time), "\n";
# (prints 09/09/2010)  
-Hades666
0
 
ozoConnect With a Mentor Commented:
If you want to convert from strings of several formats, Date::Manip can do that too,
although if you don't need all of Date::Manip's funtions, Date::Parse is a simpler module that also parses several date formats.
If all you need is month/day/year, then it may be easier to convert it yourself with POSIX::mktime
0
All Courses

From novice to tech pro — start learning today.