【发布时间】:2013-03-10 15:50:09
【问题描述】:
我需要对日期进行一些操作。 从 DB 脚本读取操作的日期和频率(例如 21 天),并应计算自实际日期以来的下一个操作时间。我已经尝试以某种方式做到这一点(我很难用英文写它,所以你可以在下面找到代码)。
//$unix_on - date from DB
//$devices[$i]['freq'] - frequency of actions
$unix_on=strtotime($devices[$i]['date_on']);
$unix_today=strtotime(date('Y-m-d'));
$actions=($unix_today-$unix_on)/(86400*$devices[$i]['freq']);
$b=explode(".", $actions);
$a='0'.'.'.$b['1'];
$f=$a*$devices[$i]['freq'];
$d=$unix_today+($f*86400);
$e=date("Y-m-d",$d);
但它不能正常工作 - 计算中有错误,我不知道为什么。
【问题讨论】:
-
请使用搜索功能。 How to add time之前已经被问过无数次了