note 99777 modified in function.date-diff by thiago

From: Date: Mon, 06 Sep 2010 13:10:26 +0000
Subject: note 99777 modified in function.date-diff by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172335@lists.php.net to get a copy of this message
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 ?> --was-- Fungsi untuk menghitung jumlah hari menggunakan sintak sql dalam php 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 ?> http://php.net/manual/en/function.date-diff.php

« previous php.notes (#172335) next »