Pogledajte određenu poruku
Staro 16. 06. 2008.   #11
misko_
profesionalac
Qualified
 
Datum učlanjenja: 22.09.2007
Lokacija: Split
Poruke: 111
Hvala: 8
39 "Hvala" u 10 poruka
misko_ is on a distinguished road
Default

Evo koda sa kojim sam ovo za datme rijesio mozda netkome zatreba.
PHP kôd:
<?php

    
class MySQL_date 
    
{
        
// site::http://boonedocks.net/mike/archives/137-Creating-a-Date-Range-Array-with-PHP.html
        
public static function createDateRangeArray($strDateFrom$strDateTo
        {
            
// takes two dates formatted as YYYY-MM-DD and creates an
            // inclusive array of the dates between the from and to dates.

            // could test validity of dates here but I'm already doing
            // that in the main script

            
$aryRange=array();

            
$iDateFrom=mktime(1,0,0,substr($strDateFrom,5,2),     substr($strDateFrom,8,2),substr($strDateFrom,0,4));
            
$iDateTo=mktime(1,0,0,substr($strDateTo,5,2),     substr($strDateTo,8,2),substr($strDateTo,0,4));

            if (
$iDateTo>=$iDateFrom) {
                
array_push($aryRange,date('Y-m-d',$iDateFrom)); // first entry

                
while ($iDateFrom<$iDateTo) {
                
$iDateFrom+=86400// add 24 hours
                
array_push($aryRange,date('Y-m-d',$iDateFrom));
                }
            }
            
            return 
$aryRange;
        }
     
        
// convert string in format dd.mm.YYYY to MySQL format http://dev.mysql.com/doc/refman/5.0/en/datetime.html YYYY-MM-DD
        // example 18.04.2008 to 2008-04-18
        
public static function ddmmYYYYtoYYYYMMDD($date)
        {
            
$parts explode("."$date);
            
            
$new_date $parts[2] . '-' $parts[1] . '-' $parts[0];
            
            return 
$new_date;
        } 
        
    }
      
?>
misko_ je offline   Odgovorite uz citat