Skip to content

Instantly share code, notes, and snippets.

@fadlisaad
Last active July 30, 2016 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fadlisaad/44b88c42ccdfd1934cde26350d9c3a43 to your computer and use it in GitHub Desktop.
Save fadlisaad/44b88c42ccdfd1934cde26350d9c3a43 to your computer and use it in GitHub Desktop.
Calculate different between two date
<?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