Hi,
I develop my PHP code on Windows Vista using WAMP/Eclipse and then deploy to a Linux environment. My WAMP environment uses PHP 5.2.8. I'm wondering why sometimes it does not appear that certain Date/Time functions exist or they do not work as documented.
1) I can find and use the DateTime class, but the DateInterval class does not seem to exist - I get a Class not found fatal error when I use DateInterval::construct. So, I wasn't able to call DateTime::sub because I am unable to create a DateInterval object. Do I have to install some sort of additional extension to get this to work?
2) If I call DateTime::modify on a DateTime object, the documentation says that the call returns a DateTime object. However, when I assign the return value to a variable the variable remains unassigned. Instead if I reference the original object, I can see it's DateTime has been modified - which essentially means I need to do a clone call to make sure I don't screw up the original object. But then why does the documentation say that the function actually returns a DateTime object?
If anyone can shed any light on these two points I'd appreciate it.
Thanks,
Steve
PHP Date Time functions - a few mysteries?
Moderator: General Moderators
-
steve_the_canuck
- Forum Newbie
- Posts: 8
- Joined: Fri Jan 30, 2009 6:36 pm
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: PHP Date Time functions - a few mysteries?
You probably need to upgrade to PHP 5.3. There have been significant improvements to DateTime in recent releases.
(#10850)