I do basic programming, I am a total noob, so please, sorry for asking a very novice question.
I was handled a project, which was working perfectly for years. Suddenly, the equation was off.
The script takes a) a submission date b) a number representing the weeks pending for delivery... then the script outputs the date of delivery, by doing this:
submission date = number of seconds that a weeks has * number of weeks for the delivery)
This is the code:
$week = 604800;
$date = strtotime( $subDate );
$newDate = $date + ($delWeek*$week);
//$newDate = date( 'Ymd', $newDate ) . 'T00:00:00';
$newDate = date( 'Y-m-d H:i:s', $newDate );
BUT, the output in these past days is that, instead of adding weeks, it is adding days...
Per example, if delivery date is 4 weeks, the ouputs adds 4 days instead of 4 weeks.
How come this happened, when the code has not changed? And how to fix this?
Try adding $delWeek
using strtotime()
:
$date = strtotime($subDate);
$newDate = strtotime("+" . $delWeek . " week", $date);
$newDate = date('Y-m-d H:i:s', $newDate);