Re: Calculate No Of Days

From: Date: Mon, 03 Jan 2005 11:55:23 +0000
Subject: Re: Calculate No Of Days
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-205503@lists.php.net to get a copy of this message
Hi Khuram I 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("today", "01/05/2005"); Note, remeber to use the correct dat format otherwise you will see some unexpected results. Jarratt On Mon, 3 Jan 2005 02:33:58 -0800 (PST), khuram noman <khuram_noman@yahoo.com> wrote: > Hi > > Is there any function avialable in PHP to calculate > the no of days by passing 2 dates like 1 argument is > 1/1/2005 and the second one is 1/2/2005 then it > returns the no of days or how can i do that if there > is no builtin function . > > Regards > Khuram Noman > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#205503) next »