check remain date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nga
Forum Commoner
Posts: 46
Joined: Mon Aug 17, 2009 3:05 am

check remain date

Post by nga »

this is my code: which used to calculate the remain day from input date imcompare with current time.

Code: Select all

$text2="2009-12-29";
 
$text4=explode("-",$text2);
if(sizeof($text4)!=3)
{
return false;
}
 
$text2 = strtotime($text2);
//plus 10 days prequisites
$text3 = strtotime(date("Y-m-d"))+60*60*24*10;
if($text3-$text2>=0)
{
$day=($text3-$text2)/(60*60*24);
echo "hi".$day;
}
else
{
$day=($text3-$text2)/(60*60*24);
echo "he".$day;
}
It's weird that it isnt working since a similar code (used to see if the input date is 10days ahead of current date is working)

Code: Select all

<?
function isLater($text2){
 
$text4=explode("-",$text2);
if(sizeof($text4)!=3)
{
return false;
}
 
$text2 = strtotime($text2);
//plus 10 days prequisites
$text3 = strtotime(date("Y-m-d"))+60*60*24*10;
if($text3-$text2>=0)
{
return false;
}
else
{
return true;
}
}
?>
Post Reply