note 84942 added to function.date
| From: | phprocks at aol dot com | Date: | Wed, 06 Aug 2008 18:25:33 +0000 |
| Subject: | note 84942 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143237@lists.php.net to get a copy of this message | ||
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.
/**
* 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);
}
----
Server IP: 64.71.164.2
Probable Submitter: 207.212.158.67
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/84942
Del: integrated -- https://master.php.net/note/delete/84942/integrated
Del: useless -- https://master.php.net/note/delete/84942/useless
Del: bad code -- https://master.php.net/note/delete/84942/bad+code
Del: spam -- https://master.php.net/note/delete/84942/spam
Del: non-english -- https://master.php.net/note/delete/84942/non-english
Del: in docs -- https://master.php.net/note/delete/84942/in+docs
Del: other reasons-- https://master.php.net/note/delete/84942
Reject -- https://master.php.net/note/reject/84942
Search -- https://master.php.net/manage/user-notes.php