doulue1949 2013-03-03 09:23
浏览 41
已采纳

是DateTime在PHP中的预定义函数或方法?

guys im helping someone with his php code. but i cant seem to figure out whats wrong with this code:

enter image description here

the system is fine in LOCALHOST. but when i uploaded it to a free hosting (000webhost.com) it gives me this error:

"Fatal error: Call to undefined method DateTime::add() in /home/a5927002/public_html/thesis2/lib/functions.php on line 273"

so i look for a function or class DateTime, i cant find it anywhere. but its working fine in localhost. any ideas guys?

  • 写回答

1条回答 默认 最新

  • drne47241 2013-03-03 09:25
    关注

    I think your local compiled with php 5.3 or greater but your shared host is compiled with php 5.2 or lower.You need PHP version 5.3.0 or higher for the add function. See the following link for more info:

    DateTime

    DateTime::modify() is an alternative when using PHP 5.2 (php.net). For example you can add 1 day to a specific date using modify function:

    $date = date_create('2006-12-12');
    date_modify($date, '+1 day');
    echo date_format($date, 'Y-m-d');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi