Knowledgebase
Portal Home > Knowledgebase > Articles Database > Count days in php
Count days in php
Posted by mohammadi, 09-14-2010, 02:00 AM How can I find the numbers of days between two dates in php?
Posted by turtus, 09-14-2010, 03:22 AM something like (not smart but should work) for dates in one year date('z', strtotime($date1)) - date('z', strtotime($date2)) for dates without time (strtotime($date1)) - strtotime($date2))) / (60*60*24) plus something for getting rid of time if you have one strtotime(date('Y-m-d', (strtotime($date1))) or floor(strtotime($date1)) / (60*60*24))
Posted by File1eu, 09-14-2010, 03:37 AM PHP always has a function for this kind of stuff: http://www.php.net/manual/en/datetime.diff.php
Posted by BurakUeda, 09-14-2010, 03:52 AM Not quite always. You need PHP 5.3+ for that function to work But yeah, that is the simplest way to do it
Add to Favourites Print this Article
Also Read