Change record status: 
Project: 
Introduced in branch: 
10.1.x
Introduced in version: 
10.1.0
Description: 

The default timestamp formatter (timestamp) now allows displaying the timestamp as a time difference (e.g. '6 months ago') instead of an absolute date/time.

Previously support for displaying a timestamp as a time difference came only from the separate timestamp_ago formatter, which outputted a static string that did not cache well. The time difference functionality now offered by the timestamp formatter uses JavaScript to both preserve cacheability and to dynamically refresh the time difference as time passes. Therefore it is superior to that offered by the timestamp_ago formatter, which may be deprecated in the future.

Related improvements:

  • Settings have been added to the timestamp formatter to control whether the timestamp should be shown as a time difference, and if so to customise the time difference.
  • The timestamp formatter now uses the HTML5 <time ...> element.
  • A title (tooltip) is present on the <time ...> element, whether or not the timestamp is displayed as a time difference. This allows for discretely providing more exact time information; this is particularly useful when displaying a time difference string, so that the user still can see the exact time by hovering over the time difference with the mouse. There is a setting on the formatter to control the format of the tooltip.
  • A javascript drupal.time-diff library has been added to core with methods that are useful in progressively enhancing time elements to show time differences; this behavior is controlled by adding the data-drupal-time-diff attribute to a element.

Not ensuring the timestamp formatter settings tooltip and time_diff is deprecated in Drupal 10.1.0. The settings are mandatory in Drupal 11.0.0.

Formatter settings form

Formatter settings form

AttachmentSize
timediff_summary.png28.25 KB
timediff_normal.png232 KB
Impacts: 
Site builders, administrators, editors
Module developers
Themers
Site templates, recipes and distribution developers