I need to make some operations on date. From the DB script is reading a date and frequency of actions (ex. 21 days), and should calculate when will be the next action since actual date. I've tried to do this in some ways (it's hard to me to write it in English, so below you can find the code).
//$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);
But it not work's fine - there are errors in calculations, and I don't know why.