public function MomentCalendar::moment in Twig Extender 4.x
Same name and namespace in other branches
- 8.4 modules/twig_extender_extras/src/Plugin/TwigPlugin/MomentCalendar.php \Drupal\twig_extender_extras\Plugin\TwigPlugin\MomentCalendar::moment()
- 8.2 modules/twig_extender_extras/src/Plugin/TwigPlugin/MomentCalendar.php \Drupal\twig_extender_extras\Plugin\TwigPlugin\MomentCalendar::moment()
- 8.3 modules/twig_extender_extras/src/Plugin/TwigPlugin/MomentCalendar.php \Drupal\twig_extender_extras\Plugin\TwigPlugin\MomentCalendar::moment()
Return date formatted in a relative date.
Parameters
string $date: The element array whose children are to be identified. Passed by reference.
string $timezone: Boolean to indicate whether the children should be sorted by weight.
Return value
array Array for render.
Throws
\Exception
See also
https://github.com/fightbulc/moment.php
File
- modules/
twig_extender_extras/ src/ Plugin/ TwigPlugin/ MomentCalendar.php, line 34
Class
- MomentCalendar
- Provide helper methods for Drupal render elements.
Namespace
Drupal\twig_extender_extras\Plugin\TwigPluginCode
public function moment($date, $timezone = NULL) {
$moment = $this
->getMoment($date, $timezone);
$build = [
'#cache' => [
'contexts' => [
'languages',
'timezone',
],
],
'#markup' => $moment
->calendar(),
];
return $build;
}