call to undefined method DateTime::add method in php

TYTY2469

New Member
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 \[code\]Call to undefined method\[/code\] error is displayed. My code is...\[code\]$date_now = new DateTime();$formatted_date = $date_now->format('Y-m-d H:i:s');$expiry_date = $date_now->add(new DateInterval('P1Y'));\[/code\]The error being displayed is...\[code\] Fatal error: Call to undefined method DateTime::add() in C:\webapps\first\system\application\models\model_first.php on line 25\[/code\]How can I resolve this? The \[code\]DateTime::format\[/code\] method works fine here.Regards
 
Back
Top