LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Convert any given time to epoch time in Perl (https://www.linuxquestions.org/questions/programming-9/convert-any-given-time-to-epoch-time-in-perl-4175599103/)

say_hi_ravi 02-06-2017 07:45 AM

Convert any given time to epoch time in Perl
 
Hi,

Any idea in perl, how can I convert a date in the format "2016-11-20 12:42:40" to epoch time.

Thanks.
Ravi

say_hi_ravi 02-06-2017 07:54 AM

Hi Folks,

Just figured out..

Quote:

/usr/bin/perl -MDate::Parse -e 'print Date::Parse::str2time("2017-02-11 15:16:48"), "\n"'
Regards,
Ravi

sundialsvcs 02-06-2017 08:14 AM

In the Perl language there are literally dozens of CPAN modules that can do anything you might imagine to do with dates and times.

(As noted below: some are built-in.)

Turbocapitalist 02-06-2017 08:14 AM

There's also Date::Calc if you need to further manipulate, compare, or calculate dates.


All times are GMT -5. The time now is 12:53 AM.