How to find days elapsed since last post in a listing page?

You can represent the date as a Unix timestamp, an integer that counts the seconds since the January 1st, 1970. Since both values below are integers we can easily subtract them and divide them by the number of seconds a day has (60 * 60 * 24 = 86400):

{{ div (sub .Now.Unix .Lastmod.Unix) 86400 }}

Remember that this value is static if you want to output it.

3 Likes