note 37832 added to function.checkdate

From: Date: Fri, 28 Nov 2003 20:53:52 +0000
Subject: note 37832 added to function.checkdate
Groups: php.notes 
Request: Send a blank email to php-notes+get-61094@lists.php.net to get a copy of this message
Example for count days between 2 dates. $start = "20030101"; $end = "20031231"; function check($x){ return (strlen($x)==1?"0".$x:$x); } $count=0; for($i = $start;$i<=$end;$i++){ $year = substr($i,0,4); $mnd = substr($i,4,2); $day = substr($i,6,2); if(checkdate ($mnd,$day,$year)){ $count++; }else{ if($mnd>12){ $mnd = "01"; $day = "00"; $year++; } if($day>=31){ $day = "00"; $mnd = check($mnd+1); } $i = $year.$mnd.$day; } } echo $count; ---- Manual Page -- http://www.php.net/manual/en/function.checkdate.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37832 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37832&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37832&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61094) next »