Tuesday, 14 August 2018

Dropdown box to have the values for the next 30 days in PHP

Selection box to get value for next 30 days.
Following PHP script should do the trick. IT will get next 30 days list.
for($j = 0; $j < 30; $j++) {

    // Get the current year, month, and day
   
    $year  = date('y');
    $month = date('m');
    $day   = date('d') + $j;
 
    // Make sure we do not have too many days for the current month...if we do, subtract the two
    
    if($day > date('t')) {
 
        $day -= date('t');
        
        // We have increased a month too, by the way
        $month += 1;
  
        // Make sure we compensate for a new year
        if($month > 12) { $month = 1; $year++; }
    }
 
    // Now make a timestamp of the current information
    $stamp = mktime(0,0,0,$month,$day,$year);
    
    // Substitue this with your dropdown code
    print date('D M d, Y', $stamp);
 echo "<br>";
} 

0 comments:

Post a Comment