template_preprocess_time(&$variables)
Prepares variables for time templates.
Default template: time.html.twig.
array $variables: An associative array possibly containing:
function template_preprocess_time(&$variables) { // Format the 'datetime' attribute based on the timestamp. // @see http://www.w3.org/TR/html5-author/the-time-element.html#attr-time-datetime if (!isset($variables['attributes']['datetime']) && isset($variables['timestamp'])) { $variables['attributes']['datetime'] = format_date($variables['timestamp'], 'html_datetime', '', 'UTC'); } // If no text was provided, try to auto-generate it. if (!isset($variables['text'])) { // Format and use a human-readable version of the timestamp, if any. if (isset($variables['timestamp'])) { $variables['text'] = format_date($variables['timestamp']); } // Otherwise, use the literal datetime attribute. elseif (isset($variables['attributes']['datetime'])) { $variables['text'] = $variables['attributes']['datetime']; } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!theme.inc/function/template_preprocess_time/8.1.x