note 48697 added to function.gmmktime

From: Date: Wed, 05 Jan 2005 08:10:25 +0000
Subject: note 48697 added to function.gmmktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-82732@lists.php.net to get a copy of this message
Here's a play on turgut85's countDays function. I've found it to be more efficient and it accepts unix timestamps rather than arrays. Thanks for the ideas. function count_days($start, $end) { // Count the days between $start and $end where both $start and $end // are UNIX timestamps // Swap the two values if end is greater than start (to avoid the // loop of death). if ($start < $end) { $t = $start; $start = $end; $end = $t; } // Increment the start time by one day until it is equal to the // end time $days = 0; while ( $start < $end ) { $start = strtotime("+1 days", $start); $days++; } return $days; } ---- Manual Page -- http://www.php.net/manual/en/function.gmmktime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48697 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48697&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48697&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48697&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48697&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48697&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48697&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48697&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#82732) next »