当日期为> = 2013-01-06
时,有人能告诉我为什么以下情况失败这太奇怪了,当这个日期过去之后,剧本完美无缺,但之前的任何事情我都会得到白色的死亡画面!
<?php
use Carbon\Carbon;
$startDate = Carbon::createFromFormat('Y-m-d', '2013-01-06');
$current_week = Carbon::now()->timestamp;
/*
$startDate = strtotime('2013-01-06');
$current_week = strtotime(date('Y-m-d'));
*/
$weeks = array();
$w = 0;
while($startDate < $current_week){
$weeks[$w] = array(
'monday' => $startDate->startofWeek()->format('d/m/Y'),
'sunday' => $startDate->endofWeek()->format('d/m/Y')
);
$w++;
$startDate = $startDate->addDays(1); // Move it on to the following week
}
var_dump($weeks);
?>
请有人帮帮我吗?!
答案 0 :(得分:1)
<?php
use Carbon\Carbon;
$startDate = Carbon::createFromFormat('Y-m-d', '2013-01-06');
$startDateTimestamp = $startDate->timestamp;
$current_week = Carbon::now()->timestamp;
/*
$startDate = strtotime('2013-01-06');
$current_week = strtotime(date('Y-m-d'));
*/
$weeks = array();
$w = 0;
while($startDateTimestamp < $current_week){
$weeks[$w] = array(
'monday' => $startDate->startofWeek()->format('d/m/Y'),
'sunday' => $startDate->endofWeek()->format('d/m/Y')
);
$w++;
$startDate = $startDate->addDays(7); // Move it on to the following week
$startDateTimestamp = $startDate->timestamp;
}
var_dump($weeks);
?>