FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


How Count Days *php*





Matee
Quote:
<?

// THIS ROUTINE COUNT DAYS BEETWEEN TWO DATE //
// BEGIN DATE COULD BE IN THE PAST OR IN THE FUTURE //
//Foro start 2005.04.19//

$beg['YEAR']=2005;
$beg['MONTH']=4;
$beg['DAY']=19;

// $data=date("d. m. Y"); deklaracja daty




$end['YEAR']=date("Y");
$end['MONTH']=date("m");
$end['DAY']=date("d");

function countDays ($beg,$end) {

$start = gmmktime(0,0,0,$beg['MONTH'],$beg['DAY'],$beg['YEAR']);
$endin = gmmktime(0,0,0,$end['MONTH'],$end['DAY'],$end['YEAR']);

// echo $start."\n";
// echo $endin."\n";

$day = 0;

if ($start < $endin) {
$toward = 1;
} else {
$toward = 0;
}

$mover = $start;

if ($start != $endin) {

do {

$day++;

if ($toward) {
$mover = gmmktime(0,0,0,$beg['MONTH'],($beg['DAY']+$day),$beg['YEAR']);
} else {
$mover = gmmktime(0,0,0,$beg['MONTH'],($beg['DAY']-$day),$beg['YEAR']);
}


} while ($mover != $endin);

}


return $day;
}

echo " Foro existing ";
echo countDays ($beg,$end). " Day's. ";

?>
Related topics
[php scripts ] phpweather&email
[tutor] How to protect images without htaccess using PHP
PHP Validation Class
Interview: Derek Liu, Gaia Online Anime Community
users online, using php and text file
Give me a special countdown script for 10frih$
handling the $_POST array
Am I allergic to the sun ?
PHP script problem
Getting unread email count using PHP
PHP Form Question
Genesis in the spotlight..1
PHP Array, explode, count , access array problem.
Guess the number of posts [Closed for Now]
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.