Mike Slinn

jekyll_time_since

Published 2020-10-03. Last modified 2023-05-18.
Time to read: 1 minutes.

This page is part of the jekyll_plugins collection.

time_since is a collection of Liquid filters that return the elapsed time since a date or date and time. The filters are years_since, months_since, days_since, hours_since, minutes_since and seconds_since.

Installation

Add the following highlighted line to your Jekyll project's Gemfile, within the jekyll_plugins group:

Shell
group :jekyll_plugins do 
  gem 'jekyll_time_since'
end 

And then execute:

Shell
$ bundle

Usage Examples

These tags all work in a similar manner; they accept one parameter, which is either a date string (YYYY-MM-dd) or an ISO 8601-1:2019 datetime string (YYYY-MM-ddThh:mm). Just a year can be specified, which implies Jan 1 at midnight.

The date and time strings can be surrounded with quotes or double quotes. Time zone can be omitted, or specified as GMT, Z, or +/- HHMM/code>.

Shell
{{ "1959" | years_since }}: 65
{{ "1959-02-03" | years_since }}: 65
{{ "1959-02-03T01:02" | years_since }}: 65
{{ "1959-02-03T01:02:00Z" | years_since }}: 65

{{ "1959" | months_since }}: 785
{{ "1959-02-03" | months_since }}: 784
{{ "1959-02-03T01:02" | months_since }}: 784
{{ "1959-02-03T01:02:00Z" | months_since }}: 784

{{ "1959" | weeks_since }}: 3416
{{ "1959-02-03" | weeks_since }}: 3411
{{ "1959-02-03T01:02" | weeks_since }}: 3411
{{ "1959-02-03T01:02:00Z" | weeks_since }}: 3411

{{ "1959" | days_since }}: 23914
{{ "1959-02-03" | days_since }}: 23881
{{ "1959-02-03T01:02" | days_since }}: 23881
{{ "1959-02-03T01:02:00Z" | days_since }}: 23881

{{ "1959" | hours_since}}: 573956
{{ "1959-02-03" | hours_since }}: 573164
{{ "1959-02-03T01:02" | hours_since }}: 573163
{{ "1959-02-03T01:02:00Z" | hours_since }}: 573168

{{ "1959" | minutes_since }}: 34437394
{{ "1959-02-03" | minutes_since }}: 34389874
{{ "1959-02-03T01:02" | minutes_since }}: 34389812
{{ "1959-02-03T01:02:00Z" | minutes_since }}: 34390112

{{ "1959" | seconds_since }}: 2066243678
{{ "1959-02-03" | seconds_since }}: 2063392478
{{ "1959-02-03T01:02" | seconds_since }}: 2063388758
{{ "1959-02-03T01:02:00" | seconds_since }}: 2063388758


* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.