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
timestampformatter to control whether the timestamp should be shown as a time difference, and if so to customise the time difference. - The
timestampformatter 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-difflibrary has been added to core with methods that are useful in progressively enhancingtimeelements to show time differences; this behavior is controlled by adding thedata-drupal-time-diffattribute 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

| Attachment | Size |
|---|---|
| timediff_summary.png | 28.25 KB |
| timediff_normal.png | 232 KB |