943,169 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 36
  • PHP RSS
Aug 31st, 2010
0

php dates dates dates

Expand Post »
hey

well i have a drop down menu or four that collects the day, month, year and number of nights spent over.

i'm havin difficulty caluclating the departure date with all this info.

can anyone help me???
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
gchurch is offline Offline
52 posts
since Aug 2010
Aug 31st, 2010
0
Re: php dates dates dates
Not unless you provide more info. Clarify the problem and show us the code.
Reputation Points: 210
Solved Threads: 228
Nearly a Posting Virtuoso
chrishea is offline Offline
1,389 posts
since Sep 2008
Aug 31st, 2010
0
Re: php dates dates dates
ok well this is what i have so far...

first page code:
<?php

$date = time();

$day = date('d', $date);
$month = date('m', $date);
$year = date('Y', $date);

//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year);

$current_month = date('F');

?>

<script type="text/javascript">

function isValidDate()
{
var now = new Date();

//advance one day
now.setDate( now.getDate() + 1 );

var Day=document.getElementById('daysOfMonth').value;
var Month=document.getElementById('monthOfYear').value;
var Year=document.getElementById('year').value;

var str = Month + " " + Day + " " + Year;

var selectedDate= new Date(str);

if(selectedDate < now)
{
alert("You may not select dates in the past . . . only future days!!!");
}
}
</script>

<select name="daysOfMonth" id="daysOfMonth" onchange="isValidDate()">
<option><?php if($day == 32){$day = 1; echo $day;}else{ echo $day + 1;} ?></option>
<option>....</option>
<?php
for($i = 1; $i <= $days_in_month; $i++)
{
echo "<option value=".$i.">".$i."</option>";
}
?>
</select>
</div></td>
<td><label for="monthOfYear"></label>
<div align="center">
<select name="monthOfYear" id="monthOfYear" onchange="isValidDate()">
<option selected="selected"><?php echo $current_month; ?></option>
<option>........</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
</div></td>
<td><label for="year"></label>
<select name="year" id="year" onchange="isValidDate()">
<option selected="selected"><?php echo $year; ?></option>
<option value="<?php echo $year + 1 ?>"><?php echo $year + 1 ?></option>
<option value="<?php echo $year + 2 ?>"><?php echo $year + 2 ?></option>
</select></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label for="nights">
<div align="right">Number of nights:</div>
</label></td>
<td><select name="nights" id="nights" onchange="this.form">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
</select></td>
---------------------------------------------------------------

reciveing page code:

$dayArrive = $_POST["daysOfMonth"];
$month = $_POST["monthOfYear"];
$year = $_POST["year"];
$nights = $_POST["nights"];
//$finish = false;

if($nights == 1)
$night = "night";
else
$night = "nights";
---

<table width="100%" border="0" cellpadding="6" style="margin-bottom:30px">
<tr>
<td align="center">Coastal View B+B<div id="returnPage"><a href="CheckAvailability.php" target="_self">Return to previous page</a></div></td>
</tr>
<tr style="background-image:url(images/UIHeaderBreak.jpg); background-repeat:repeat-x">
<td>&nbsp;</td>
</tr>
<tr>
<td><b>Arrival:</b><?php echo $dayArrive ." ". $month ." ". $year?></td>
</tr>
<tr>
<td><b>Leaving:</b><?php echo $dayLeave ." ". @$month2 ." ". $year?></td>
</tr>
<tr>
<td><b>Staying:</b><?php echo $nights . " " . $night ?></td>
</tr>
</table>
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
gchurch is offline Offline
52 posts
since Aug 2010
Aug 31st, 2010
0
Re: php dates dates dates
do you need more info or is this cool?

basically i recieve a day, month, year and number of nights to stay... then i need to work out the leavin date and display...

i have some code there but getting nowhere fast
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
gchurch is offline Offline
52 posts
since Aug 2010
Sep 1st, 2010
0
Re: php dates dates dates
ok i figured it out

thanks anywho
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
gchurch is offline Offline
52 posts
since Aug 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Making of Hindi WebSite
Next Thread in PHP Forum Timeline: login codes





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC