Page date from CSS Selector
Updating out of date content and ensuring that content is being reviewed on a regular basis is an important element of website maintenance.
Focus on newly created pages might also be interesting for you as a web editor, or monitoring modified pages over the last week in an administrator role.
The Page date from CSS Selector rule in Policy enables you to set up policies relating to all of the scenarios above.
This rule can be set up to pick up dates provided in a structured way on a website.
*To keep setup minimal only a fixed set of date formats are allowed, and only dates provided without context are valid (that is, dates in the middle of a sentence aren't supported).
Identifying dates on pages
Identifying the HTML element on the page containing the date is done using a CSS selector.
The following example illustrates a meta tag in the head-section of each page carrying the date of the last modification of the page:
... <head> <title>My page</title> <meta name="Last-Modified" content="2015-09-24T19:12:22Z" /> <meta name="description" content="My important content is on this page" /> </head> ...
This date can be picked up by Policy using a CSS selector. The CSS selector to match the
Last-Modified meta tag would be:
As described above, Policy will automatically identify the date in the
content attribute, so the name of the attribute isn't significant. But of course we recommend sticking to attributes that are valid HTML.
We also highly recommend using meta tags to carry dates.
Supported date formats
Only three formats are supported: Variants of ISO 8601, RFCs 1123, 5322 and 2822 as well as Unix Epoch dates.
Supports three granularities: Date, date with time, and date with time and fractions.
ddd, dd, MMM yyyy HH:mm:ss GMT
ddd, dd, MMM yyyy HH:mm:ss K
Mon, 15 Jun 2009 20:45:30 GMT
Mon, 15 Jun 2009 20:45:30 +0100
|Variants are commonly used for HTTP date headers, such as the Last-Modified header.
Day and month names must be in English, as per the RFCs.
No timezone identifier is interpreted as UTC.
Time must be in 24-hour format.
|Unix Epoch||A large whole number||1443052852||The number of seconds since 1st of January 1970 (also known as the Unix Epoch).
The date will be interpreted as UTC.
What is ISO 8601?
ISO 8601 is an an internationally accepted way to represent dates and times using numbers.
Due to the different ways that date formats are written from country to country, it is incredibly easy to misinterpret dates.
11/03/15, could mean 11th March 2015 or 3rd November 2015.
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.
11th March 2015: 2015-03-11
3rd November 2015: 2015-11-03
A separate document is available if you would like to send these formats to your website provider to make appropriate changes, updates or to ensure that one of these formats is being used consistently throughout the site.Date formats supported by Siteimprove Policy
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.