Skip to main content

Page date from CSS Selector

Modified on: Fri, 9 Oct, 2026 at 2:18 PM

Summary

The Page date from CSS Selector policy rule identifies dates in page elements and evaluates them against policy conditions, helping teams monitor newly created, recently modified, or out-of-date content. It supports ISO 8601, RFC, and Unix Epoch date formats.

Overview

Updating out-of-date content and ensuring that content is being reviewed on a regular basis is an important element of website maintenance.

As a web editor, you might want to focus on newly created pages, and an administrator might want to monitor pages that have been modified during the last week.

The "Page date from CSS Selector" policy rule can use certain date formats in the HTML code, enabling you to set up policies relating to the scenarios above.

Identifying dates on pages

Identifying the HTML element that contains the date is done using a CSS selector. The following example shows two <meta> tags in the <head> section of a page, and the first one shows when the page was last modified:

<head>

<title>My page</title>

<meta name="Last-Modified" content="2020-09-24T19:12:22Z" />

<meta name="Description" content="A description of the page's content" />

</head>

The CSS selector to match this "Last-Modified" meta tag would be meta[name='Last-Modified']. The policy will check if this element has any attribute with a valid date format and use that as the date. (In this case, it's the "content" attribute.)

Supported date formats

Three date formats are supported:

  • Variants of ISO 8601
  • RFCs 1123, 5322, 2822
  • Unix Epoch

ISO 8601

Supported formats:

  • yyyy-MM-dd
    • Example: 2020-09-24
  • yyyy-MM-ddTHH:mm:ssK
    • Examples: 
      • 2020-09-24T19:12:22Z
      • 2020-09-24T19:12:22+0000
      • 2020-09-24T19:12:22+02:00
  • yyyy-MM-ddTHH:mm:ss.FFFFFFFK
    • Examples: 
      • 2020-09-24T19:12:22.0000000Z
      • 2020-09-24T19:12:22.0000000+0000

Notes:

  • Supports three granularities: 
    • Date only
    • Date and time
    • Date, time, and fractions of a second
  • Time must use 24-hour format.
  • Time zones can be: 
    • Z (UTC)
    • +01:00
    • +0100
  • If no timezone is specified, UTC is assumed.

RFC 1123, RFC 5322, and RFC 2822

Supported formats:

  • ddd, dd, MMM yyyy HH:mm:ss GMT
    • Example: 
      • Thu, 24 Sep 2020 19:12:22 GMT
  • ddd, dd, MMM yyyy HH:mm:ss K
    • Examples: 
      • Thu, 24 Sep 2020 19:12:22 +0100
      • Thu, 24 Sep 2020 19:12:22 +01:00
      • Thu, 24 Sep 2020 19:12:22

Notes:

  • Commonly used in HTTP date headers such as Last-Modified.
  • Day and month names must be in English.
  • Time must use 24-hour format.
  • If no timezone is specified, UTC is assumed.

Unix Epoch

Format:

  • A large whole number

Example:

  • 1600967542

Notes:

  • Represents the number of seconds since January 1, 1970.
  • Interpreted as UTC.

Programming language examples

The following table shows how to construct valid dates using the built-in date functions in a range of programming languages:

What is ISO 8601?

ISO 8601 is an international standard for writing dates and times. Due to different date formats in different countries, it is very easy to misinterpret dates, e.g. confusing the numbers for days and months.

In 1988, the ISO (International Organization for Standardization) set a Global standard numeric date format, which was recognized internationally as the agreed way to represent dates:

  • YYYY-MM-DD
  • 2020-03-11: 11th March 2020
  • 2020-11-03: 3rd November 2020

How the Date‑Matching Rule Works

The date‑matching rule applies broadly to any CSS selector. When the rule evaluates an element, it checks all attributes and the element’s inner text to determine whether any value looks like a valid date. If a date‑like value is found and it satisfies the specified condition (for example, “newer than X date”), the rule considers the element a match.

To avoid false positives, the date must represent at least January 1, 1970.

Recognized Date Formats

The rule supports several formats, including:

  • ISO 8601 with milliseconds
  • ISO 8601 with optional milliseconds
  • ISO 8601 without milliseconds
  • ISO 8601 date‑only
  • RFC1123
  • RFC5322 / RFC2822

Want to learn more about CSS selectors?

Interested to learn more about CSS selectors? Read our article CSS Selectors & Siteimprove Policy and try out the CSS Selector rule in your policies.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.