Hi all
my question is about duo date
by reference of this thread
I read the MySQL's DATEDIFF(expr1,expr2) but still I dont know how it will be work.
Mr. pswason told to use SELECT DATEDIFF(expiration_date, CURDATE()) WHERE id=$id;
and he dont know about ... he says "I don't know if a card is considered expired if the expiration date is the current date"
I give the current date as not expiration date so I make my script as:
$tdy = date('Ymd');
in detail our many cards have expiry date like 19-08-2011, and we like to see how much days remaining by substract today date from.
my whole code is
<?php
$timezone = new DateTimeZone( "Asia/Riyadh" );
$date = new DateTime();
$date->setTimezone( $timezone );
echo $today = $date->format( 'H:i:s A / D, M jS, Y' );
echo '<br />';
function datediff ($expri, $tdy)
{
$tdy = date('Ymd');
$tmr = (($expri - $tdy)/100*30); // $expri will be take from DB.
return $tmr;
}
$query = 'SELECT * FROM staff';
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC) )
{
echo '<tr valign="top">';
echo '<td>' . $row['id'] .
'</td> <td>'. $row['name'] .
'</td><td align="center">' . $row['nationality'] .
'</td><td align="center">' . $row['card_no'];
'</td><td align="center">';
$exdate = 'SELECT DATEDIFF(card_expiry_date, CURDATE())';// I dont know how to use mysql's condtions in php.
echo '</td><td align="center">' . datediff($expri = $row['card_expiry_date'], $tdy);
echo '</tr>';
}
mysql_free_result($result);
mysql_close();
?>