|
<?
$datex =
"2003-02-10"
$number_of_day_left
= SafgetDiff($datex)
if ($datex <
10 ) {
print "You can
display here new image in front of your product"
}else{
//just leave it new product not found
}
//========This is the function
function
SafgetDiff($d)
{
list($y,$m,$d)
= explode("-",$d);
$timestamp =
mktime(0,0,0,$m,$d,$y);
$d2 =
time();
$diff =
$d2 -
$timestamp;
$days =
floor($diff
/ 86400);
//86400 = 60*60*24 (sec*min*hr) and floor
will give you a base (not .0023 no)
return $days;
}
/*NOTE :
Please use the date format when your are saving to database like date('y-m-d'),
bcos MySql database date format is yyyy-mm-dd (2003-02-18) so don't mix up
this*/
?>
|