Assuming you're starting at April 12th, then May 3rd would be 3 weeks and May 31st would be 7 weeks. So my guess is that when you pass "2.7", it is ignoring the "2." portion of that string.
You could consider calculating the number of days to add separately, such as:
$averageWeeks = 2.7;
$averageDays = floor($averageWeeks * 7);
$laidDate->modify('+'.$averageDays.' days');
Consider also that 2.7 weeks is 18.9 days. By taking the floor
, We are adding 18 days. It doesn't make since to add fractional days here, unless you intend to change the time of day as well. If you did, you'd have to do some additional math, as it doesn't appear that either modify
or add
will support fractional values. You could do something like this:
$averageWeeks = 2.7;
$averageSeconds = floor($averageWeeks * 7 * 24 * 60 * 60);
$laidDate->modify('+'.$averageSeconds.' seconds');
But you might be fooling yourself if you think this time is accurate, since not every local day has exactly 24 hours in it, due to daylight saving time transitions.