Reputation:
I've tired to add 10 weekdays to now. Everything is OK, but it clears the time part. Do you know why?
$now = date("Y-m-d H:i:s");
echo $now.'<br>';
$mod = strtotime($now." +10 weekdays");
echo $mod.'<br>';
echo date("Y-m-d H:i:s",$mod).'<br>';
Output:
2011-05-23 14:34:02
1307311200
2011-06-06 00:00:00
My expected output were:
2011-06-06 14:34:02
Thanks.
Upvotes: 3
Views: 2912
Reputation: 449525
Looks like a difference in interpretation.
You could do the following to enforce the time:
<?php
$date = date("Y-m-d");
$time = date("H:i:s");
echo $date.' '.$time.'<br>';
$mod= strtotime($date." +10 weekdays $time");
echo $mod.'<br>';
echo date("Y-m-d H:i:s",$mod).'<br>';
Upvotes: 5
Reputation: 2195
There are several examples on the PHP documentation which can help you add days while still preserving the times.
Upvotes: -2