Date Array (Opgelost) 		
			
		
		 		
				
		
                        
                 
            
            
				
                
                    mightymike (laatste wijziging 28/11/2007 10:35)                       
             
             
                        
                PHP interesse 
				
				Goede dag,
    
    
        
            
                
$datum[2000]
$datum[2001]
 
             
            
         
         
     
 
    
    
        
            
                
$datum[01-2000]
$datum[02-2000]
$datum[03-2000]
$datum[04-2000]
$datum[05-2000]
//.
//.
//.
$datum[01-2001]
 
             
            $datum [ 01 - 2000 ] 
$datum [ 02 - 2000 ] 
$datum [ 03 - 2000 ] 
$datum [ 04 - 2000 ] 
$datum [ 05 - 2000 ] 
//. 
//. 
//. 
$datum [ 01 - 2001 ] 
 
         
     
 
    
    
        
            
                
<?
$second = mktime(0,0,1,0,0,0) - mktime(0,0,0,0,0,0);
$minute = mktime(0,1,0,0,0,0) - mktime(0,0,0,0,0,0);
$hour = mktime(1,0,0,0,0,0) - mktime(0,0,0,0,0,0);
$day = mktime(0,0,0,0,1,0) - mktime(0,0,0,0,0,0);
$week = mktime(0,0,0,0,7,0) - mktime(0,0,0,0,0,0);
$month = mktime(0,0,0,1,0,0) - mktime(0,0,0,0,0,0);
$year = mktime(0,0,0,0,0,1) - mktime(0,0,0,0,0,0);
//Controle op schaalfilter
switch($aWizardPages[1][values]['scalerate']) {
			
	case 1:
	
		//uur
		$sqldate = "YYYY-MM-DD HH24";
		$pdate = "Y-m-d H";
		$count = $hour;
		$detail = tell("HOUR");
		break;
					
	case 2:
				
		//dag
		$sqldate = "YYYY-MM-DD";
		$pdate = "Y-m-d";
		$count = $day;
		$detail = tell("DAY");
		break;
					
	case 3:
				
		//week
		$sqldate = "YYYY WW";
		$pdate = "Y W";
		$count = $week;
		$detail = tell("WEEK");
		break;
					
	case 4:
		
		//maand
		$sqldate = "YYYY-MM";
		$pdate = "Y-m";
		$count = $month;
		$detail = tell("MONTH");
		break;
					
	case 5:
			
		//jaar
		$sqldate = "YYYY";
		$pdate = "Y";
		$count = $year;
		$detail = tell("YEAR");
		break;
					
	}		
			
//Creer een data array
$x = 0;
for($i=strtotime($aWizardPages[1][values][datumvan]);$i<strtotime($aWizardPages[1][values][datumtot]);$i+=$count) {
	$data[date($pdate, $i)] = array();
	$data[$x] = date($pdate, $i);
				
	$x++;
			
}
 
             
            <? 
 
$second  =  mktime ( 0 , 0 , 1 , 0 , 0 , 0 )  -  mktime ( 0 , 0 , 0 , 0 , 0 , 0 ) ; $minute  =  mktime ( 0 , 1 , 0 , 0 , 0 , 0 )  -  mktime ( 0 , 0 , 0 , 0 , 0 , 0 ) ; $hour  =  mktime ( 1 , 0 , 0 , 0 , 0 , 0 )  -  mktime ( 0 , 0 , 0 , 0 , 0 , 0 ) ; $day  =  mktime ( 0 , 0 , 0 , 0 , 1 , 0 )  -  mktime ( 0 , 0 , 0 , 0 , 0 , 0 ) ; $week  =  mktime ( 0 , 0 , 0 , 0 , 7 , 0 )  -  mktime ( 0 , 0 , 0 , 0 , 0 , 0 ) ; $month  =  mktime ( 0 , 0 , 0 , 1 , 0 , 0 )  -  mktime ( 0 , 0 , 0 , 0 , 0 , 0 ) ; $year  =  mktime ( 0 , 0 , 0 , 0 , 0 , 1 )  -  mktime ( 0 , 0 , 0 , 0 , 0 , 0 ) ;  
//Controle op schaalfilter 
switch ( $aWizardPages [ 1 ] [ values] [ 'scalerate' ] )  { 
 
	case  1 : 
 
		//uur 
		$sqldate  =  "YYYY-MM-DD HH24" ; 
		$pdate  =  "Y-m-d H" ; 
		$count  =  $hour ; 
		$detail  =  tell( "HOUR" ) ; 
		break ; 
 
	case  2 : 
 
		//dag 
		$sqldate  =  "YYYY-MM-DD" ; 
		$pdate  =  "Y-m-d" ; 
		$count  =  $day ; 
		$detail  =  tell( "DAY" ) ; 
		break ; 
 
	case  3 : 
 
		//week 
		$sqldate  =  "YYYY WW" ; 
		$pdate  =  "Y W" ; 
		$count  =  $week ; 
		$detail  =  tell( "WEEK" ) ; 
		break ; 
 
	case  4 : 
 
		//maand 
		$sqldate  =  "YYYY-MM" ; 
		$pdate  =  "Y-m" ; 
		$count  =  $month ; 
		$detail  =  tell( "MONTH" ) ; 
		break ; 
 
	case  5 : 
 
		//jaar 
		$sqldate  =  "YYYY" ; 
		$pdate  =  "Y" ; 
		$count  =  $year ; 
		$detail  =  tell( "YEAR" ) ; 
		break ; 
 
	} 		
 
//Creer een data array 
$x  =  0 ; 
for ( $i = strtotime ( $aWizardPages [ 1 ] [ values
] [ datumvan
] ) ; $i < strtotime
( $aWizardPages [ 1 ] [ values
] [ datumtot
] ) ; $i += $count )  {  
	$data [ $x ]  =  date ( $pdate ,  $i ) ;   
	$x ++; 
 
} 
 
         
     
  
              
        
		
				
		5 antwoorden 
                
                     
                
                    
		
		
	             
 
            
                    
                         
                    
                    
                        
                            Thomas (laatste wijziging 28/11/2007 11:21)                             
                         
                     
                    
                        Moderator Ik zou $data niet telkens (elke stap van de lus) berekenen, maar eenmalig wat berekeningen uitvoeren. Een heleboel dingen liggen al vast, zoals het aantal uren in een dag, het is niet echt zinnig om hier aan te rekenen. 
                      
                
                    
                         
                    
                    
                        
                            mightymike                             
                         
                     
                    
                        PHP interesse het tricky valt wel mee
    
    
        
            
                
$data[01-01-2007 01] //Per uur
$data[01-01-2007] //Per Dag
$data[2007 01] //Per week
$data[01-2007] //Per maand
$data[2007] //Per jaar
 
             
            $data [ 01 - 01 - 2007  01 ]  //Per uur 
$data [ 01 - 01 - 2007 ]  //Per Dag 
$data [ 2007  01 ]  //Per week 
$data [ 01 - 2007 ]  //Per maand 
$data [ 2007 ]  //Per jaar 
 
         
     
  
                      
                
                    
                         
                    
                    
                        
                            Thomas                             
                         
                     
                    
                        Moderator Ik zou ook zoveel mogelijk via een standaard werken (datetime). Enige uitzondering hierop is dan je week-variant... 
                      
                
                    
                         
                    
                    
                        
                            marten                             
                         
                     
                    
                        Beheerder Mike, 
                      
                
                    
                         
                    
                    
                        
                            mightymike                             
                         
                     
                    
                        PHP interesse heb het inmiddels al geregeld door de mktime functie op een andere manier te gebruiken
    
    
        
            
                //Controle op schaalfilter
			switch($aWizardPages[1][values]['scalerate']) {
			
				case 1:
				
					//uur
					$sqldate = "YYYY-MM-DD HH24";
					$pdate = "Y-m-d H";
					$detail = tell("HOUR");
					break;
					
					for($x=0; $x<=(datediff('h',$aWizardPages[1][values][datumvan], $aWizardPages[1][values][datumtot])+1); $x++){
					
						$data[$x] = date($pdate,mktime(date('H', strtotime($aWizardPages[1][values][datumvan])) + $x,0,0,date('m', strtotime($aWizardPages[1][values][datumvan])),date('d', strtotime($aWizardPages[1][values][datumvan])),date('Y', strtotime($aWizardPages[1][values][datumvan]))));
						$data[date($pdate,mktime(date('H', strtotime($aWizardPages[1][values][datumvan])) + $x,0,0,date('m', strtotime($aWizardPages[1][values][datumvan])),date('d', strtotime($aWizardPages[1][values][datumvan])),date('Y', strtotime($aWizardPages[1][values][datumvan]))))] = array();
					
					}
					
				case 2:
				
					//dag
					$sqldate = "YYYY-MM-DD";
					$pdate = "Y-m-d";
					$detail = tell("DAY");
					
					for($x=0; $x<=(datediff('d',$aWizardPages[1][values][datumvan], $aWizardPages[1][values][datumtot])+1); $x++){
					
						$data[$x] = date($pdate,mktime(0,0,0,date('m', strtotime($aWizardPages[1][values][datumvan])),date('d', strtotime($aWizardPages[1][values][datumvan])) + $x,date('Y', strtotime($aWizardPages[1][values][datumvan]))));
						$data[date($pdate,mktime(0,0,0,date('m', strtotime($aWizardPages[1][values][datumvan])),date('d', strtotime($aWizardPages[1][values][datumvan])) + $x,date('Y', strtotime($aWizardPages[1][values][datumvan]))))] = array();
					
					}
					
					break;
					
				case 3:
				
					//week
					$sqldate = "YYYY WW";
					$pdate = "Y W";
					$detail = tell("WEEK");
					
					for($x=0; $x < datediff('ww',$aWizardPages[1][values][datumvan], $aWizardPages[1][values][datumtot]); $x++){
					
						$data[$x] = date($pdate,mktime(0,0,0,date('m', strtotime($aWizardPages[1][values][datumvan])),date('d', strtotime($aWizardPages[1][values][datumvan])) + (7 * $x),date('Y', strtotime($aWizardPages[1][values][datumvan]))));
						$data[date($pdate,mktime(0,0,0,date('m', strtotime($aWizardPages[1][values][datumvan])),date('d', strtotime($aWizardPages[1][values][datumvan])) + (7 * $x),date('Y', strtotime($aWizardPages[1][values][datumvan]))))] = array();
					
					}	
					
					break;
					
				case 4:
				
					//maand
					$sqldate = "YYYY-MM";
					$pdate = "Y-m";
					$detail = tell("MONTH");
					
					for($x=0; $x<=(datediff('m',$aWizardPages[1][values][datumvan], $aWizardPages[1][values][datumtot])+1); $x++){
					
						$data[$x] = date($pdate,mktime(0,0,0,date('m', strtotime($aWizardPages[1][values][datumvan])) + $x,date('d', strtotime($aWizardPages[1][values][datumvan])),date('Y', strtotime($aWizardPages[1][values][datumvan]))));
						$data[date($pdate,mktime(0,0,0,date('m', strtotime($aWizardPages[1][values][datumvan])) + $x,date('d', strtotime($aWizardPages[1][values][datumvan])),date('Y', strtotime($aWizardPages[1][values][datumvan]))))] = array();
					
					}				
					
					break;
					
				case 5:
					
					//jaar
					$sqldate = "YYYY";
					$pdate = "Y";
					$detail = tell("YEAR");
					
					for($x=0; $x<=datediff('yyyy',$aWizardPages[1][values][datumvan], $aWizardPages[1][values][datumtot]); $x++){
					
						$data[$x] = date($pdate,mktime(0,0,0,date('m', strtotime($aWizardPages[1][values][datumvan])),date('d', strtotime($aWizardPages[1][values][datumvan])),date('Y', strtotime($aWizardPages[1][values][datumvan])) + $x));
						$data[date($pdate,mktime(0,0,0,date('m', strtotime($aWizardPages[1][values][datumvan])),date('d', strtotime($aWizardPages[1][values][datumvan])),date('Y', strtotime($aWizardPages[1][values][datumvan])) + $x))] = array();
					
					}	
					break;
					
			}		 
             
            //Controle op schaalfilter 
			switch ( $aWizardPages [ 1 ] [ values] [ 'scalerate' ] )  { 
 
				case  1 : 
 
					//uur 
					$sqldate  =  "YYYY-MM-DD HH24" ; 
					$pdate  =  "Y-m-d H" ; 
					$detail  =  tell( "HOUR" ) ; 
					break ; 
 
					for ( $x = 0 ;  $x <= ( datediff( 'h' , $aWizardPages [ 1 ] [ values] [ datumvan] ,  $aWizardPages [ 1 ] [ values] [ datumtot] ) + 1 ) ;  $x ++ ) { 
 
						$data [ $x ]  =  date ( $pdate , mktime ( date ( 'H' ,  strtotime ( $aWizardPages [ 1 ] [ values
] [ datumvan
] ) )  +  $x , 0 , 0 , date ( 'm' ,  strtotime ( $aWizardPages [ 1 ] [ values
] [ datumvan
] ) ) , date ( 'd' ,  strtotime ( $aWizardPages [ 1 ] [ values
] [ datumvan
] ) ) , date ( 'Y' ,  strtotime ( $aWizardPages [ 1 ] [ values
] [ datumvan
] ) ) ) ) ;  						$data [ date ( $pdate , mktime ( date ( 'H' ,  strtotime ( $aWizardPages [ 1 ] [ values
] [ datumvan
] ) )  +  $x , 0 , 0 , date ( 'm' ,  strtotime ( $aWizardPages [ 1 ] [ values
] [ datumvan
] ) ) , date ( 'd' ,  strtotime ( $aWizardPages [ 1 ] [ values
] [ datumvan
] ) ) , date ( 'Y' ,  strtotime ( $aWizardPages [ 1 ] [ values
] [ datumvan
] ) ) ) ) ]  =  array ( ) ;   
					} 
 
				case  2 : 
 
					//dag 
					$sqldate  =  "YYYY-MM-DD" ; 
					$pdate  =  "Y-m-d" ; 
					$detail  =  tell( "DAY" ) ; 
 
					for ( $x = 0 ;  $x <= ( datediff( 'd' , $aWizardPages [ 1 ] [ values] [ datumvan] ,  $aWizardPages [ 1 ] [ values] [ datumtot] ) + 1 ) ;  $x ++ ) { 
 
 
					} 
 
					break ; 
 
				case  3 : 
 
					//week 
					$sqldate  =  "YYYY WW" ; 
					$pdate  =  "Y W" ; 
					$detail  =  tell( "WEEK" ) ; 
 
					for ( $x = 0 ;  $x  <  datediff( 'ww' , $aWizardPages [ 1 ] [ values] [ datumvan] ,  $aWizardPages [ 1 ] [ values] [ datumtot] ) ;  $x ++ ) { 
 
 
					} 	
 
					break ; 
 
				case  4 : 
 
					//maand 
					$sqldate  =  "YYYY-MM" ; 
					$pdate  =  "Y-m" ; 
					$detail  =  tell( "MONTH" ) ; 
 
					for ( $x = 0 ;  $x <= ( datediff( 'm' , $aWizardPages [ 1 ] [ values] [ datumvan] ,  $aWizardPages [ 1 ] [ values] [ datumtot] ) + 1 ) ;  $x ++ ) { 
 
 
					} 				
 
					break ; 
 
				case  5 : 
 
					//jaar 
					$sqldate  =  "YYYY" ; 
					$pdate  =  "Y" ; 
					$detail  =  tell( "YEAR" ) ; 
 
					for ( $x = 0 ;  $x <= datediff( 'yyyy' , $aWizardPages [ 1 ] [ values] [ datumvan] ,  $aWizardPages [ 1 ] [ values] [ datumtot] ) ;  $x ++ ) { 
 
 
					} 	
					break ; 
 
			} 
 
         
     
  
                      
                
                    
                         
                    
                        
		
		
	             
 
                
Dit onderwerp is gesloten .