Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding weekdays - clears the time

Tags:

php

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.


1 Answers

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>';
like image 169
Pekka Avatar answered Sep 21 '26 03:09

Pekka