Last active
July 30, 2016 22:35
-
-
Save fadlisaad/44b88c42ccdfd1934cde26350d9c3a43 to your computer and use it in GitHub Desktop.
Calculate different between two date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function daysTo($from, $to, $round=true) | |
{ | |
$diff = $to-$from; | |
$days = ($diff/86400)+1; | |
return $round==true ? floor($days) : round($days,2); | |
} | |
//usage | |
$from = strtotime($start_date); // tarikh mula | |
$to = strtotime($end_date); //tarikh akhir | |
echo daysTo($from, $to, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment