Copy link to clipboard
Copied
I am converting a mySQL date to PHP and then attempting to add days to it for the output. Here is what I have so far:
$tempDate = strtotime($row['duedate']);
$newDate = date("Y-m-d",$tempDate);
$fiveDaysLater = strtotime(date("Y-m-d", strtotime($newDate) . " +1 day"));
Output:
1303192800
The date I am taking from MySQL is 2011-04-19.
I really just need to output the new PHP date as something like 04/20/2011 or something similar. Any help is appreciated!
Thanks.
P.S. - If anyone knows, can you please let me know if adding enough days will take you to the next month, or will it wrap around back to the first of the month?
Copy link to clipboard
Copied
echo date('m/j/Y', $fiveDaysLater);
Adding days will take you to the next month. It will not wrap.
Copy link to clipboard
Copied
Rob, thanks for the formatting help for my output.
I found the solution:
The placment of my parenthesis was wrong:
$fiveDaysLater = strtotime(date("Y-m-d", strtotime($newDate) . " +1 day"));
Here is the correct version (corrections on both lines in red):
$fiveDaysLater = strtotime(date("Y-m-d", strtotime($newDate)) . " +1 day");
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more