请问这种计算工作时间结束的具体时间戳 应该怎么写
起始时间是随机的日期时间戳是X
总共需要工作6天才能完成
但是上班时间只有5天/周
我想得到下周几才能完成,包括具体的时间戳,星期几
这里要如何判断周六日,把他们再每一次都隔过去呢
麻烦写个完整代码,感谢
------解决思路----------------------
<br /><?php<br /><br />$start_time =rand(time(), time() + 50 * 24 * 60 * 60);<br /><br />$needed_time = 23; //day<br /><br />$work_day = 5;<br /><br />$needed_week = floor($needed_time/$work_day);<br /><br />$end_time = $start_time + $needed_week * 7 * 24 * 60 * 60 + $needed_time%$work_day * 24 * 60 * 60;<br /><br />$end_date = date("Y-m-d", $end_time);<br /><br />$start_date = date("Y-m-d", $start_time);<br /><br />$end_week_day = date("w", $end_time);<br /><br />$weeks = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");<br /><br />echo "start date: $start_date, end date: $end_date, " . $weeks[$end_week_day] . " after ". $needed_week . " weeks.";<br /><br />
<br /><?php<br /><br />$start_time =rand(time(), time() + 50 * 24 * 60 * 60);<br /><br />$needed_time = 23; //day<br /><br />$work_day = 5;<br /><br />$needed_week = floor($needed_time/$work_day);<br /><br />$end_time = $start_time + $needed_week * 7 * 24 * 60 * 60 + $needed_time%$work_day * 24 * 60 * 60;<br /><br /><br />$weeks = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");<br /><br />$end_week_day = date("w", $end_time);<br /><br />if($end_week_day == 6 <br><font color='#FF8000'>------解决思路----------------------</font><br> $end_week_day == 0)<br />{<br /> $needed_week ++;<br /> $end_time += 2 * 24 * 60 * 60;<br />}<br />$end_date = date("Y-m-d", $end_time);<br /><br />$start_date = date("Y-m-d", $start_time);<br /><br />$end_week_day = date("w", $end_time);<br /><br /><br />echo "start date: $start_date, end date: $end_date, " . $weeks[$end_week_day] . " after ". $needed_week . " weeks.";<br /><br />
$x = '2015-07-27';<br />$d = 6;<br /><br />$t = strtotime($x);<br />while($d > 1) { //当天不算就 $d > 0<br /> $t += 86400;<br /> if(in_array(date('w', $t), array(6,0))) continue;<br /> $d--;<br />}<br />echo date('Y-m-d w', $t);