...

View Full Version : generate 5 dates



gadaschowdary
01-13-2010, 08:32 PM
how to generate 5 dates in a drop down list .
based on noofdays value that many dates should be generated. I am using this but it is giving 01/01/1970.

plz help



Reservation Date :&nbsp;</td>
<td align="left"><select name="ResrvDate" type="text" class="textbox" id="ResrvDate" value="">
<?$Count = 0;

while($Count < $NoOfDays){
$dates= date("m/d/Y",strtotime(date("m/d/Y", strtotime($date)) . " + " . $Count . " day")) . "<br />";
?>
<option value = "<?echo $dates?> "> <? echo $dates ?> </option>
<? $Count++;}?>

JAY6390
01-13-2010, 08:37 PM
What is the value of $date? Do an echo before that line to see. Also What is with the strtotime(date(strtotime(date))) stuff? You shouldn't need all that

mlseim
01-13-2010, 08:48 PM
Describe the starting date, and what the other 5 dates would look like.

gadaschowdary
01-13-2010, 10:05 PM
I am new to this stuff. I got this code from google.

coming to the start date will be current day's date. in mm/dd/yyyy format.
$todaysdate = date("m/d/Y");


so every day when some one views the page the dates should be 5 days dates from that date.

Len Whistler
01-13-2010, 10:42 PM
<?php

echo "<select>";

$counter = 1;

while ($counter <= 5 ) {
$date = date('Y-m-d', strtotime(" + $counter day"));
echo "<option value=\" $date\"> $date </option>\n";
$counter++;
}

echo "</select>";

?>

gadaschowdary
01-14-2010, 04:47 PM
thanx!! it worked



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum