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

Anyone know a library to render DateTime objects into "yesterday", "last week", "three months ago"... etc? Thanks!
  • Comment on Perl module to "humanise" dates and times

Replies are listed 'Best First'.
Re: Perl module to "humanise" dates and times (grep.metacpan.org)
by LanX (Saint) on May 19, 2023 at 11:14 UTC
      Nice! Good tip... Thanks for all replies - I am on my way again...
Re: Perl module to "humanise" dates and times
by hippo (Archbishop) on May 19, 2023 at 11:08 UTC

    Since your example strings are all relative and in the past I would suggest starting with Time::Duration::ago.


    🦛

Re: Perl module to "humanise" dates and times
by 1nickt (Canon) on May 19, 2023 at 12:23 UTC

    Hi, I use and can recommend Time::Ago.

    use Time::Ago; print Time::Ago->in_words($dt->epoch), "\n";
    Hope this helps!


    The way forward always starts with a minimal test.
Re: Perl module to "humanise" dates and times
by GrandFather (Saint) on May 20, 2023 at 09:32 UTC

    Not quite what you want, but maybe interesting: Approximate time

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
Re: Perl module to "humanise" dates and times
by salva (Canon) on May 20, 2023 at 16:56 UTC