note 43016 added to function.mktime
| From: | shadow2day at yahoo dot com | Date: | Sun, 06 Jun 2004 23:49:59 +0000 |
| Subject: | note 43016 added to function.mktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-70559@lists.php.net to get a copy of this message | ||
can't figure out what's wrong with this..anyone
--
<?
#########################
# date_diff Function
#########################
#
# Calculate the difference between 2 dates in YYYY-MM-DD format.
# Returns the number of days difference.
if (date_diff($today, $end_date) > 0) {
echo 'Active';
} else {
echo 'Expired';
};
function date_diff($today, $end_date)
{
$today=now();
$d1 = explode("-", $today);
$y1 = $d1[0];
$m1 = $d1[1];
$d1 = $d1[2];
$d2 = explode("-", $end_date);
$y2 = $d2[0];
$m2 = $d2[1];
$d2 = $d2[2];
$today_set = mktime(0,0,0, $m1, $d1, $y1);
$end_date_set = mktime(0,0,0, $m2, $d2, $y2);
return(round(($end_date_set-$today_set)/(60*60*24)));
} ;
?>
----
Manual Page -- http://www.php.net/manual/en/function.mktime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43016
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43016&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43016&report=yes
Search -- http://master.php.net/manage/user-notes.php