-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime elapsed
More file actions
29 lines (24 loc) · 726 Bytes
/
time elapsed
File metadata and controls
29 lines (24 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?
$nowtime = time();
$oldtime = GetValueInteger(37742 /*[Eltako FSB61\Start Time]*/); //Startzeit
$count = time_elapsed($nowtime-$oldtime);
$prozent = $count / 56 *100;
$timeprint = round($count / 56 * 100)."% (".$count.")";
SetValue(57245 /*[Eltako FSB61\Time Elapsed]*/, $timeprint);
/** Output:
Gerät eingeschaltet: 6d 15h 48m 19s
**/
function time_elapsed($secs){
$bit = array(
'y' => $secs / 31556926 % 12,
'w' => $secs / 604800 % 52,
'd' => $secs / 86400 % 7,
'h' => $secs / 3600 % 24,
'm' => $secs / 60 % 60,
's' => $secs % 60
);
foreach($bit as $k => $v)
if($v > 0)$ret[] = $v . $k;
return join(' ', $ret);
}
?>