note 99777 deleted from function.date-diff by danbrown
| From: | danbrown@php.net | Date: | Mon, 06 Sep 2010 15:12:03 +0000 |
| Subject: | note 99777 deleted from function.date-diff by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172338@lists.php.net to get a copy of this message | ||
Note Submitter: Ardian - StudioKami[dot]com
----
Function to calculate the number of days using sql syntax on php
<?php
function countday($startdate,$enddate)
{
$query = "SELECT datediff('$enddate','$startdate') as selisih";
$hasil = mysql_query($query);
$data = mysql_fetch_array($hasil);
$jmlhari = $data['selisih'];
return $jmlhari;
}
echo "Example : ". countday("2010-09-06","2010-09-10") . "
day";
//hasil--------- Example : 4 day
?>