'count days in dates' Tag

  • How to count days between 2 dates in php

    March 11, 2013

    A simple solution to count days between 2 dates is using DateTime method since php 5.3 function getDaysBetweenDates($from,$to,$addLastDay = false){ $d1 = new \DateTime($from); $d2 = new \DateTime($to); if($addLastDay){ $d2->add(new \DateInterval('P1D')); } return $d1 -> diff($d2)->days; } echo getDaysBetweenDates('2013-03-01','2013-03-11'); //10 echo getDaysBetweenDates('2013-03-01','2013-03-11',true); //11 If you need to count the last day too , just pass […]

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org