我想创建一个从00:00所有恒温5分钟时间数组23:55创建阵列timelist从00:00 - 23:55为每5分钟
在这个论坛上,我发现:
$minutes = 5;
$endtime = new DateTime('2012-01-01 09:00');
//modified the start value to get something _before_ the endtime:
$time = new DateTime('2012-01-01 00:00');
$interval = new DateInterval('PT' . $minutes . 'M');
while($time < $endtime){
$time->add($interval);
echo $time->format('Y-m-d H:i');
}
我该如何改变它,以便输出可以用于json?
例如: -
$ aArray = { “00:00”: “00:00”, “00:05”: “00:05”,......“23时55分“:”23:55“}
我的问题不是在创建JSON,而是在创建没有日期部分的小时/分钟列表。
然后,我会用一对嵌套循环来生成数组内容。请参阅我更新的答案。 – 2013-04-08 21:20:39