Add view helper functions for formatting, date, date and time, and time

refs #6778
This commit is contained in:
Eric Lippmann 2015-05-19 10:10:23 +02:00
parent a66cb907ae
commit d53c3d7075

View File

@ -10,6 +10,27 @@ $this->addHelperFunction('format', function () {
return Format::getInstance(); return Format::getInstance();
}); });
$this->addHelperFunction('formatDate', function ($date) {
if (! $date) {
return '';
}
return DateFormatter::formatDate($date);
});
$this->addHelperFunction('formatDateTime', function ($dateTime) {
if (! $dateTime) {
return '';
}
return DateFormatter::formatDateTime($dateTime);
});
$this->addHelperFunction('formatTime', function ($time) {
if (! $time) {
return '';
}
return DateFormatter::formatTime($time);
});
$this->addHelperFunction('timeAgo', function ($time, $timeOnly = false) { $this->addHelperFunction('timeAgo', function ($time, $timeOnly = false) {
if (! $time) { if (! $time) {
return ''; return '';