now Object

Date object containing the current date and time.

Attributes

None.

Category

Global Objects

Description

This object contains a date containing the current date and time.

You’ll typically use the date filter to format the object into a human-readable string:

{{ now | date: '%-m/%-d/%Y' }}

You may also find yourself using now in date-based math:

      {% assign current_year = now | date: '%Y' %}
      {% assign the_year = published_at | date: '%Y' %}
      {% age_in_years = current_year | minus: the_year %}
      
      {% if age_in_years > 5 %}
        <p class="alert">
          <strong>Old Post Alert!</strong>
          It's been {{ age_in_years }} since we've published
          this article.
        </p>
      {% endif %}