Hall of Famer Posted February 24, 2011 Share Posted February 24, 2011 Tried to use a datetime addition function but it gave me this error: Fatal error: Call to undefined function date_add() in /home2/cruxispr/public_html/mysidiaadoptables/devdemo/script.php on line 3 I searched on PHP tutorials, but it says there's no need to install any of these datetime related functions since they are part of PHP core. I dont understand, why do I get a no method error like this if it is indeed already in PHP core? Please help. Here are the links from PHP official site for references: http://www.php.net/manual/en/datetime.installation.php http://www.php.net/manual/en/datetime.add.php Quote Link to comment https://forums.phpfreaks.com/topic/228660-php-date-intervals/ Share on other sites More sharing options...
kenrbnsn Posted February 24, 2011 Share Posted February 24, 2011 What version of PHP are you running? The date_add function is only available in version 5.3 and later. Ken Quote Link to comment https://forums.phpfreaks.com/topic/228660-php-date-intervals/#findComment-1178969 Share on other sites More sharing options...
Hall of Famer Posted February 24, 2011 Author Share Posted February 24, 2011 This is what I see from cpanel: PHP version 5.2.16 So yeah, looks like this is the problem. Is it possible for a hosting service to upgrade PHP? o_o Also are there any other functions that I can manipulate with dates? For instance, what am I supposed to do if I have a petsite in which an egg hatches like, say 5 days after it is laid? Please help... Quote Link to comment https://forums.phpfreaks.com/topic/228660-php-date-intervals/#findComment-1179117 Share on other sites More sharing options...
kenrbnsn Posted February 24, 2011 Share Posted February 24, 2011 You will have to talk to your hosting company. Some will upgrade, some won't. On versions below 5.3, you can use strtotime in combination with date. Ken Quote Link to comment https://forums.phpfreaks.com/topic/228660-php-date-intervals/#findComment-1179139 Share on other sites More sharing options...
AbraCadaver Posted February 24, 2011 Share Posted February 24, 2011 You will have to talk to your hosting company. Some will upgrade, some won't. On versions below 5.3, you can use strtotime in combination with date. Ken Yes, strtotime() is great. If you show what you want to do with the dates, it should be fairly straight forward. Quote Link to comment https://forums.phpfreaks.com/topic/228660-php-date-intervals/#findComment-1179141 Share on other sites More sharing options...
PFMaBiSmAd Posted February 24, 2011 Share Posted February 24, 2011 If your DATE/DATETIME information happens to be stored in a database, most databases have a number of date/time functions, such as - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-add Quote Link to comment https://forums.phpfreaks.com/topic/228660-php-date-intervals/#findComment-1179142 Share on other sites More sharing options...
Hall of Famer Posted February 24, 2011 Author Share Posted February 24, 2011 Thank you for answering my question everyone, much appreciated. I happened to find that there's a date_add() function in mysql, so I wonder if it is possible to use use a mysql query line to add/substract dates: http://www.w3schools.com/sql/sql_dates.asp How do these mysql functions work? Do they also require PHP 5.3 or higher? Quote Link to comment https://forums.phpfreaks.com/topic/228660-php-date-intervals/#findComment-1179301 Share on other sites More sharing options...
jcbones Posted February 24, 2011 Share Posted February 24, 2011 NO, MySQL is not PHP. They use MySQL. MySQL Date/Time functions Quote Link to comment https://forums.phpfreaks.com/topic/228660-php-date-intervals/#findComment-1179302 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.