If you started writing a PHP script where the logic is in days, you many need to find days between two dates. This situation occurs often if you are working as a Professional PHP Web Developer.
Lets pick two dates and convert the string to time using strtotime(), then find the days dividing them by 60*60*24:
1 2 3 4 5 6 7 8 9 10 11 |
<?php $date1 = '2013-11-10'; $date2 = '2013-11-01'; $diff = strtotime($date1) - strtotime($date2); $days = $diff/(60*60*24). " days"; echo $days; ?> |
I hope this would have helped you.