调用未定义的方法DateTime :: add方法在php [英] call to undefined method DateTime::add method in php
本文介绍了调用未定义的方法DateTime :: add方法在php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用php 5.2.9作为xampp安装的一部分。我正在为我的webapp使用codeigniter框架。当我调用DateTime :: add时,会显示调用未定义方法
错误。我的代码是...
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
我该如何解决? DateTime :: format
方法在这里很好。
How can I resolve this? The DateTime::format
method works fine here.
注意
推荐答案
我认为你最少需要PHP 5.3.0或更高版本的添加功能。有关详细信息,请参阅以下链接: PHP手册 - DateTime :: add
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
这篇关于调用未定义的方法DateTime :: add方法在php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文