Jump to content

PHP date intervals...


Hall of Famer

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/228660-php-date-intervals/
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/228660-php-date-intervals/#findComment-1179117
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/228660-php-date-intervals/#findComment-1179141
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/228660-php-date-intervals/#findComment-1179301
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.