Is there some built-in or third-party function I can use for the following?

The function

(elfeed-entry-date entry)

returns the timestamp for an RSS feed entry, e.g. 1518282912.0.

I would like to use this as

(message "%s" (elfeed-entry-date entry))

but instead of 1518282912.0 the result should be

2 hours ago or n days ago or x years ago ...

What I tried: Did some googling, found a somewhat related SO question that deals with Clojure.

There's also a ruby method called distance_of_time_in_words but of course this question is about Elisp.

  • 1
    For those of us who are unfamiliar with elfeed and may not immediately recognize the time format 1518282912.0, it may be helpful to let the readers know what that format is. Once we know, we can all do Google searches such as: emacs convert elfeed absolute days to hours, and so on. Then, someone can write up a custom solution if it does not exist. Alternatively, consider providing us with a link to the source code beginning line that defines elfeed-entry-date.
    – lawlist
    Feb 10, 2018 at 19:14
  • What @lawlist said. FWIW, relevant Emacs formatting functions include seconds-to-string, format-seconds and format-time-string. See the relevant sub-nodes of (elisp) System Interface. If you use Gnus there is also the function gnus-user-date in lisp/gnus/gnus-sum.el whose output can be customised via the alist gnus-user-date-format-alist.
    – Basil
    Feb 10, 2018 at 19:23
  • (elfeed-entry-date entry) returns the same type as the emacs builtin (float-time) Feb 11, 2018 at 2:38


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.