note 94208 deleted from function.strtotime by derick

From: Date: Sun, 03 Nov 2013 15:22:08 +0000
Subject: note 94208 deleted from function.strtotime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197412@lists.php.net to get a copy of this message
Note Submitter: heiko dot dressler at dresden-it dot de ---- here is a simple function to compare dates and build ranges. <?php $germanDates = array('10.10.2009','25.12.2009', '01.02.2009','11.10.2009', '12.10.2009','13.10.2009', '11.10.2010','01.03.2010', '28.02.2010'); $DateArray = array(); $rangeArray=array(); foreach($germanDates as $Index=>$Date) { // create timestamp from german date [ easy :-) ] $DateArray[$Date]= strtotime($Date); } // sort timestamps asort($DateArray); // read the array and create ranges $RangeIndex = 0; $Counter = 0; $ReadDateStamp = 0; foreach($DateArray as $Index=>$Datum) { if($Counter<=0) { // init first value and create range array $rangeArray[$RangeIndex][$Index]=$Datum; }else{ // compare new date mit Readstamp $Diff = $Datum - $ReadDateStamp; if($Diff != 86400) { $RangeIndex++; } $rangeArray[$RangeIndex][$Index]=$Datum; } $ReadDateStamp = $Datum; $Counter++; } ?> 86400 = 1 day

« previous php.notes (#197412) next »