I am using php 5.2.9 as a part of xampp installation. I am using codeigniter framework for my webapp. When I call upon DateTime::add, the Call to undefined method
error is displayed. My code is...
$date_now = new DateTime();
$formatted_date = $date_now->format('Y-m-d H:i:s');
$expiry_date = $date_now->add(new DateInterval('P1Y'));
The error being displayed is...
Fatal error: Call to undefined method DateTime::add() in C:\webapps\first\system\application\models\model_first.php on line 25
How can I resolve this? The DateTime::format
method works fine here.
Regards
I think you minimally need PHP version 5.3.0 or higher for the add function. See the following link for more info: PHP manual - DateTime::add
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With