note 36797 added to function.date

From: Date: Wed, 22 Oct 2003 19:36:36 +0000
Subject: note 36797 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-59146@lists.php.net to get a copy of this message
This cals different days between given date and today. function daysDiff($y1, $m1, $d1) { $y2 = date("Y"); $m2 = date("m"); $d2 = date("d"); if (mktime(0,0,0,$m1,$d1,$y1) - mktime(0,0,0,date("m"),date("d"),date("Y"))<0) { $diff = "expiried"; } else { $y = $y1 - $y2; $m = $m1 - $m2; $d = $d1 - $d2; $daysInMonth = date("t",$m1); if ($d<0) {$m--;$d=$d+$daysInMonth;} if ($m<0) {$y--;$m=$m+12;} if ($y>0) $diff .= $y==1 ? "1 year " : "$y years "; if ($m>0) $diff .= $m==1? "1 month and " : "$m months and "; if ($d>0) $diff .= $d==1 ? "1 day " : "$d days "; $diff .= " remaining"; } return $diff; } April White. ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36797 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36797&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36797&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#59146) next »