Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Add PHP function to Volt

Hello, i want to use PHP's strtotime function on volt. I followed the tutorial and include the following code in the services.php file:

$view = new View();
$volt = new Volt($view, $di);
$compiler = $volt->getCompiler();
$compiler->addFunction('strtotime', 'strtotime');

But, when i tried it, it says strtotime is undefined. Is there a specific place where i need to put those code or there's something else ?


Try adding volt to the di

$di['volt'] = $volt;


It works. Thanks :D