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

There are any date related wrappers in Phalcon?

Date wrappers would be really useful to help dealing with date outputs and calculations, example:

$this->date->today('Y-m-d'); // 2014-09-15
$this->date->today('Y-m-d','-1'); // 2014-09-14

$this->date->thisMonth('F') // September
$this->date->thisMonth('F','-1') // August

// ... etc

And there could be a DI setting to the default locale so you could define it "globally" on your project.

Would be really useful. There is something related in Phalcon already?


You can use the built-in PHP datetime:


$d = new \DateTime();
$d->modify('-1 days');
echo $d->format('Y-m-d'); // 2014-09-14

$d = new \DateTime();
echo $d->format('F'); // September

$d->modify('-1 month');
echo $d->format('F'); // August

// ... etc