We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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 ?



6.4k
Accepted
answer

Try adding volt to the di

$di['volt'] = $volt;


6.6k

It works. Thanks :D