Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

how can I find the diffrence between two dates when each is in a diffrent format like (Y-m-d , d/m/Y)..But I don't want to use strtotime

user-image
Question added by Faizan Ahmad , Software Engineer , cardekho.com
Date Posted: 2013/04/05
Marouen Sayari
by Marouen Sayari , Senior PHP Programmer and Full-time Freelancer, Zend Certified Engineer , Self-employed

Since PHP 5.3 you can use the DateTime class Example: $date1 = new DateTime('date string'); $date2 = new DateTime('second date string'); $interval = $date1->diff($date2); echo $interval->format('%d'); //%d for number of days

you can (explode) the characters (/, -) from the two dates , and compare them with any algorithm you want .

Faizan Ahmad
by Faizan Ahmad , Software Engineer , cardekho.com

Rather days between two dates

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.