Forum Moderators: coopster
When you select, say March 1, 2004 for the check-in date, the check-out date will be immidately changed to March 2, 2004, without the need to use the calendar again.
Thanks.
---------
I was searching online during the past week with the hope to find the solution by myself, but failed.
So I turned to webmasterworld.com.
I tried strftime
A friend offered me the code:
$checkindate = explode("-", $checkindate);
list($year, $month, $day) = $checkindate;
$checkoutdate = strftime("%Y-%m-%d", mktime(0,0,0,$month,$day+$nights,$year)); //$nights being the interval
echo "begin date $checkindate to $checkoutdate";
Confused!
[edited by: Yangtze at 5:31 am (utc) on Mar. 28, 2004]
as for changing your date, look into date() functions on PHP's Date manual [php.net]
INSERT INTO your_table
(checkindate, checkoutdate)
VALUES('2004-03-28', DATE_ADD(checkindate, INTERVAL 4 DAY))
;
There is a related javascript solution found here at WebmasterWorld:
DATE_ADD with JavaScript [webmasterworld.com]
You suggested:
INSERT INTO your_table (checkindate, checkoutdate) VALUES('2004-03-28', DATE_ADD(checkindate, INTERVAL 4 DAY))I'm sorry but may I ask where should I input this set of php code?
And should I check the code to:
INSERT INTO your_table (checkindate, checkoutdate) VALUES('checkindate', DATE_ADD(checkindate, INTERVAL 4 DAY))
This is not PHP code, it is a MySQL query statement. The example I explained was to clarify what the
DATE_ADDfunction is in MySQL and how it works (as asked in msg #2).
No, you cannot change the code as you requested, you will end up with a NULL value in your checkindate column as it is not a valid date.
If it were me, I'd ask for a checkindate, validate the date, and then display the checkindate as well as the calculated checkoutdate during "approval" or "verify-your-entries" processing. If you want to show the checkoutdate prior to form submittal, you can use a client-side scripting language such as javascript. In addition, you should calculate and verify the checkoutdate on the server-side prior to processing.