PHP Date Time functions - a few mysteries?
Posted: Thu Feb 11, 2010 10:50 am
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
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