Jump to content

Display Dates


euel

Recommended Posts

Hi again!

I'm trying to use this code that i found somewhere in the net to display all the dates between 2 dates.

It is exactly what i need but..

I understand the code and its structure (i think) but it gives me an error (maximum execution time of blah blah) which i think is

because it makes an infinite loop(not sure..  :))

 

function GetDays($sStartDate, $sEndDate)
{   
$sStartDate = gmdate("Y-m-d", strtotime($sStartDate));  
$sEndDate = gmdate("Y-m-d", strtotime($sEndDate));  
        
     $aDays[] = $sStartDate;  
      
     $sCurrentDate = $sStartDate;  
      
      while($sCurrentDate < $sEndDate){  
        $sCurrentDate = gmdate("Y-m-d", strtotime("+1 day", strtotime($sCurrentDate)));  
      
        $aDays[] = $sCurrentDate;  
      }  
      
      return $aDays;  
    }  

 

 

Appreciate the help and suggestions!

Gonna browse the forums for answers for the meantime...

Link to comment
https://forums.phpfreaks.com/topic/254324-display-dates/
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.