dm404
asked on
ADDDATE function using a variable
Hi there,
I'm having trouble using ADDDATE function in PHP. I want to add 2 days to m $edt variable that I set at the top of my page.
I'm guessing it should follow these lines...
ADDDATE(date, INTERVAL 2 DAY).
I can't get the variable $edt to work tho. I get a Parse error: syntax error, unexpected T_LNUMBER
Here's a snippet of my code...
I'm having trouble using ADDDATE function in PHP. I want to add 2 days to m $edt variable that I set at the top of my page.
I'm guessing it should follow these lines...
ADDDATE(date, INTERVAL 2 DAY).
I can't get the variable $edt to work tho. I get a Parse error: syntax error, unexpected T_LNUMBER
Here's a snippet of my code...
$edt2 = ADDDATE("$edt", INTERVAL 2 DAY);
echo $edt2;
ASKER
Hi,
Yep that works although I need the value to be in a YYYY-MM-DD
Thanks in advance,
Daniel
Yep that works although I need the value to be in a YYYY-MM-DD
Thanks in advance,
Daniel
ASKER
Sorry that didn't work.
It comes up with
Thu, 01 Jan 1970 00:00:00 +0000 !!
It comes up with
Thu, 01 Jan 1970 00:00:00 +0000 !!
What is the content of $edt?
try this
$edt2 = date('Y-m-d', strtotime(strtotime($edt)." plus 2 days"));
ASKER
$edt is a variable set in two ways.
1) Form is submitted, uses a JS calendar so the value will always be in the format YYYY-MM-DD.
2) Form not submitted takes current date in format YYYY-MM-DD.
afzz your code returns 1970-01-01, which is the correct format just not the correct date.
Thanks again,#
Daniel
1) Form is submitted, uses a JS calendar so the value will always be in the format YYYY-MM-DD.
2) Form not submitted takes current date in format YYYY-MM-DD.
afzz your code returns 1970-01-01, which is the correct format just not the correct date.
Thanks again,#
Daniel
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yep that works.
Thankyou very much!
Thankyou very much!
$edt2 = date('r', strtotime("$edt plus 2 days"));