Laravel used Carbon (I think).
You can install Carbon. For example via composer
$ composer require nesbot/carbon
and create filter
$di->set('volt', function ($view, $di) {
$volt = new VoltEngine($view, $di);
$volt->setOptions(array(
"compiledPath" => APP_PATH . "cache/volt/",
));
$compiler = $volt->getCompiler();
$compiler->addFilter('diffForHumans', function($resolvedArgs, $exprArgs){
return '\Carbon\Carbon::createFromFormat("Y-m-d H:i:s", '.$resolvedArgs.')->diffForHumans()';
});
return $volt;
}, true);
$di->set('view', function () use ($config) {
$view = new View();
$view->setViewsDir(APP_PATH . $config->application->viewsDir);
$view->registerEngines(array(
".volt" => 'volt'
));
return $view;
});
In Volt template
Registered: {{ user.created_at|diffForHumans }}<br>