PHP: Calculate duration between two dates
<?php $date11 = '2013-03-12'; $date22 = '2013-03-15'; $date11 = strtotime($date11); $date22 = strtotime($date22); $diff = $date22 - $date11; $diff_in_days = floor($diff/(60*60*24)); echo $diff_in_days; // 3 ?>
<?php $date11 = '2013-03-15'; $date22 = '2013-03-12'; $date11 = strtotime($date11); $date22 = strtotime($date22); $diff = $date22 - $date11; $diff_in_days = floor($diff/(60*60*24)); echo $diff_in_days; // -3 ?>
Comments
Post a Comment