note 44998 deleted from function.checkdate by tomsommer

From: Date: Sun, 22 Aug 2004 23:59:37 +0000
Subject: note 44998 deleted from function.checkdate by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75137@lists.php.net to get a copy of this message
Note Submitter: steven at pluginz dot com ---- There's a much easier way to count days, like the post above yours... because, remember: dates are just numbers. ;-) <?php // the following can all be done in one line... heh $start = "20030101"; $end = "20031231"; $et = strtotime($end); // 1072846800 $st = strtotime($start); // 1041397200 $diff = $et - $st; $count = $diff / (60*60*24); // get days $count++; // only if you want an inclusive count. echo $count; ?> Result: 365 (with the count incremented for inclusion) The inclusive increment is necessary because subtraction just works that way, and to prove the calculation above: if $start = "20000101" and $end = "20010101" result is 366 days ... a leap year. :-) QED ==_-+- Steve

« previous php.notes (#75137) next »