r:date_format
This outputs a date. It can be used to pull the date from when a blog post or page was published, output the time, day, and/or year on page render, and has among many other uses.
Attribute Options
format
- Tells the tag how to output the date. For example: 11/01/14
or November 1, 2014. Acceptable values come from
strftime or are one of the following three standard values: rfc822
,
iso8601
, httpdate
.
value
- This is the string you're getting from CleanSlate (aka the whole
point of this tag). Under the hood, CleanSlate uses the
Chronic library to parse the value attribute. So any date/time value supported
by Chronic can be parsed.
Example:
<r:date_format format="%Y" value="now" />
{{ page.published_at | date: "%A, %B %d, %Y" }}
This outputs a date. It can be used to pull the date from when a blog post or page was published, output the time, day, and/or year on page render. It has many other uses.
In Liquid, you access the native date via {{ page.published_at }}
or {{ article.published_at }}
, then pipe in the date filter to output the date in the format you desire.
Under the hood, CleanSlate uses the Chronic library to parse the original value. So, any date/time value supported by Chronic can be parsed.
Filter options
date
- Tells the tag how to output the date. For example: 11/01/14
, now
, or November 1, 2014
. Acceptable values come from strftime.
date_iso8601
- Outputs a date in ISO 8601 format, eg: 2018-05-09T18:02:37-04:00
.
date_rfc2822
- Outputs a date in Internet Message Format, eg: Wed, 09 May 2018 18:02:37 -0400
.
Examples:
{{ page.published_at | date: "%A, %B %d, %Y" }}
<!-- Outputs: Wednesday, May 09, 2018 -->
{{ article.published_at | date: "%Y" }}
<!-- Outputs: 2021 -->
{{ page.updated_at | date_rfc2822 }}
<!-- Outputs: Wed, 09 May 2018 18:02:37 -0400 -->
This page was last updated at {{ "now" | date: "%Y-%m-%d %H:%M" }}.
<!-- Outputs: This page was last updated at 2019-09-19 17:48. -->
<p>Seconds since 1970: {{ "now" | date: "%s" }}</p>
<!-- Outputs: Seconds since 1970: 1614897261 -->
Last updated on March 15, 2021.
We welcome all questions, feedback and bug reports. If you're having an issue, we usually need the following information:
- A brief description of the issue
- A link to the page where you saw the issue
- Screenshots that illustrate the problem - How do I take a screenshot?
Kindly email CleanSlate@mail.wvu.edu for help or use the form on the request help page.