note 84942 deleted from function.date by tularis

From: Date: Thu, 09 Feb 2012 20:59:57 +0000
Subject: note 84942 deleted from function.date by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-186001@lists.php.net to get a copy of this message
Note Submitter: phprocks at aol dot com ---- Try this for finding the difference in days between 2 dates/datetimes... take note though, date_parse requires PHP version 5.1.3 or higher. <?php /** * Finds the difference in days between two calendar dates. * * @param Date $startDate * @param Date $endDate * @return Int */ function dateDiff($startDate, $endDate) { // Parse dates for conversion $startArry = date_parse($startDate); $endArry = date_parse($endDate); // Convert dates to Julian Days $start_date = gregoriantojd($startArry["month"], $startArry["day"], $startArry["year"]); $end_date = gregoriantojd($endArry["month"], $endArry["day"], $endArry["year"]); // Return difference return round(($end_date - $start_date), 0); } ?>

« previous php.notes (#186001) next »