bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

any module i can use to get such output from 2018-10-25 13:45:32

to

2 hours ago

Replies are listed 'Best First'.
Re: time format
by Anonymous Monk on Jan 13, 2019 at 19:22 UTC
    DateTime::Format::Human::Duration

      thanks

Re: time format
by thanos1983 (Parson) on Jan 14, 2019 at 15:14 UTC

    Hello bigup401,

    Fellow Monks have already proposed solutions to your problem. I would like to add also another possible way.

    I prefer to use the module Date::Manip regarding Date/Time manipulations/calculations. You can find also here a few basic examples Date::Manip::Examples.

    #!/usr/bin/perl use strict; use warnings; use Date::Manip; use feature 'say'; my $date1 = ParseDate("now"); my $date2 = ParseDate("2 hours ago"); my $delta = DateCalc($date1, $date2, 1); say $delta; say Delta_Format($delta,"Was %hv hours, %mv minutes, %sv seconds"); __END__ $ perl test.pl 0:0:0:0:-2:0:0 Was -2 hours, 0 minutes, 0 seconds

    Hope this helps, BR.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
Re: time format
by NetWallah (Canon) on Jan 14, 2019 at 04:55 UTC
    The core module Time::Piece is associated with the (also core) Time::Seconds ,
    which provides the "pretty()" method which should do the job.

    Older versions of the module do not have that method, so I have had to hack my own using "can()" to find if pretty exists, and use my hack if not (For systems where I could not upgrade perl/modules).

                    As a computer, I find your faith in technology amusing.