Alternative to DateTime::diff() method in php 5.2

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 87
Joined: Wed May 16, 2012 4:17 pm

Tue Oct 02, 2012 5:26 pm

Good day everyone, I need some help about this

you see my development environment is php 5.3 while the live one is 5.2
I've been using php DateTime's diff() method,
it worked perfectly on the local until I found out 5.2 didn't support it

here is the error

[php]Fatal error: Call to undefined method DateTime::diff() in /home/solution/public_html/wp-content/themes/J/_includes/_controllers/contr_createshortlist.php on line 195[/php]

is there a work around for this?

all my code does is

get the difference of 2 dates (in yyyy-mm-dd) format



then the difference is 1 year and 2 months (I need the difference of the year and the month)

another ex


then the difference is 1 year and 0 months

the day is difference is not important

hope you can help me with this thank you in advance

Post Reply