Note Submitter: Carlos Pauluk carloseduardopauluk gmail
Reason: useless
----
I've been using the mktime() function to calculate
difference between dates. It works fine to me until I need
to do calculation in more wide dates, like 01/01/2070.
There will be a huge problem to all those that use
timestamps to calculate dates after
2038-01-19T03:14:08+0000Z (like posted by PHPCoder).
I got a code from "google" (thanx to Amrit Hallan)
that can successfully calculate the difference *in days*
between two dates.
<?php
function dateDiff($dformat, $endDate, $beginDate) {
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1],
$date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1],
$date_parts2[2]);
return $end_date - $start_date;
}
?>
You can use it like these:
<?php
echo dateDiff("/", "01/31/2070",
"01/31/2000");
?>
It should returns 25568 (days between).
I wish that help.
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|