I'm trying to make a script to return the next 5 days for example today is 2006-04-24 and it would create variables with the values of 2006-04-25, 2006-04-26, 2006-04-27, 2006-04-28, 2006-04-29. I thought and using getdate function and add +1~5 to day value but I realized it would bug after the day gets over 30. Any suggestions?

Look in the manual for checkdate();
Maybe this will help you.

I'm trying to make a script to return the next 5 days for example today is 2006-04-24 and it would create variables with the values of 2006-04-25, 2006-04-26, 2006-04-27, 2006-04-28, 2006-04-29. I thought and using getdate function and add +1~5 to day value but I realized it would bug after the day gets over 30. Any suggestions?

I don't think checkdate will help greatly. Try mktime() instead.

The php manual entry for "date" reads:

It is possible to use date() and mktime() together to find dates in the future or the past. Example 3. date() and mktime()example

<?php
$tomorrow  = mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"));
$lastmonth = mktime(0, 0, 0, date("m")-1, date("d"),  date("Y"));
$nextyear  = mktime(0, 0, 0, date("m"),  date("d"),  date("Y")+1);
?>

Try this function:
int strtotime ( string time [, int now] )

Try this function:
int strtotime ( string time [, int now] )

How will this help in obtaining variables with consecutive dates in them?

you can do it like in such way

$dates_array = array();
for ($i=0; $i<5; $i++) {
  $dates_array[] = date('Y-m-d', strtotime("+$i days"));
}

hmmm... ok.

I prefer my solution though!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.