Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

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

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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

Postby jplus2 » 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

ex.

2010-01-01
2011-03-01

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

another ex

2010-01-01
2011-01-01

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
jplus2
New php-forum User
New php-forum User
 
Posts: 87
Joined: Wed May 16, 2012 4:17 pm

Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron