Just note that Gabriel's answer is probably the cleanest way to do it, but If you would prefer using a PHP function:
http://www.codingforums.com/archive/index.php/t-140522.html Cancer10's code worked great for me: <?php function datediff($date1,$date2,$format='d'){ $difference = abs(strtotime($date2) - strtotime($date1)); switch (strtolower($format)){ case 'd': $days = round((($difference/60)/60)/24,0); break; case 'm': $days = round(((($difference/60)/60)/24)/30,0); break; case 'y': $days = round(((($difference/60)/60)/24)/365,0); break; } return $days; } echo datediff('2008-8-1','2007-8-30','D') . ' Days'; echo datediff('2008-8-1','2007-8-30','m') . ' Months'; echo datediff('2008-8-1','2007-8-30','y') . ' Years'; ?> Plus you could tweak this code a bit if you would like seconds, minutes, hours or weeks. Thing is, this will not work out to well for leap years. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
