We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

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 ?



6.4k
Accepted
answer

Try adding volt to the di

$di['volt'] = $volt;


6.6k

It works. Thanks :D