Page 1 of 1

Date

Posted: Tue Mar 29, 2005 2:53 am
by bobbyaa
Is there a way to take a date that a user submits, and add to it. For example, they submit the date 03/11/05 and i would add three and it would now have the value of 03/14/05.

Thanks
Robert

Posted: Tue Mar 29, 2005 3:29 am
by anjanesh

Code: Select all

echo date("m/d/y", strtotime("03/11/05")+(3*24*60*60));

Posted: Tue Mar 29, 2005 5:20 am
by JayBird

Code: Select all

echo date("m/d/y", strtotime("03/11/05 + 3 days"));
will do the same

and just for info
Just a comment that the strtotime function supports American date format before it supports English date format.

$input = "02/01/2000";

$time = strtotime($input);

$output = date("Ymd", $time);

For the example date above, the output will be 20000201.

However, for the 29th January 2000 (29/01/2000) the output is 20020501

so it assumes mm/dd/yyyy rather than dd/mm/yyyy