Reputation: 1683
guys im helping someone with his php code. but i cant seem to figure out whats wrong with this code:
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?
Upvotes: 0
Views: 177
Reputation: 1849
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::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');
Upvotes: 2