Re: Days remaining?

From: Date: Fri, 03 Dec 2004 11:16:59 +0000
Subject: Re: Days remaining?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-203414@lists.php.net to get a copy of this message
Hi Peter, You can use this function function daysLeft($startDate,$endDate=false){ // convert to timestamps $start_stamp = strtotime($startDate); $end_stamp = ($endDate)?strtotime($endDate):time(); if($start_stamp > $end_stamp){ // start date is passed end date return "0"; } $difference = $end_stamp - $start_stamp; return floor($difference/(24*60*60)); } echo daysLeft('2004-12-20','2004-12-25'); HTH Jarratt

« previous php.general (#203414) next »