-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_functions_wt.php
46 lines (35 loc) · 1.15 KB
/
util_functions_wt.php
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/*
* Project: Smart Water Tank
* Created by: Jitesh Saini
*/
//----------------------Tank Dimensions--------------------------------------------
global $dia, $height;
//$dia=41; //inches
//$height=46; //inches (height of sensor)
$dia=104; //cm
$height=402; //cm (height of sensor)
//---------------utility functions-------------------------------------------------------
function calculate_volume($dia,$septic_level){
$radius=$dia/2;
$vol_cubic_cm=(3.142) * $radius * $radius * $septic_level;
//$vol_litres = $vol_cubicInches * 0.0163871;
$vol_litres = $vol_cubic_cm * 0.001;
return round($vol_litres,1);
}
//read_data.php
function timeago2($timestamp) {
$strTime = array("second", "minute", "hour", "day", "month", "year");
$length = array("60","60","24","30","12","10");
$currentTime = time();
if($currentTime >= $timestamp) {
$diff = time()- $timestamp;
for($i = 0; $diff >= $length[$i] && $i < count($length)-1; $i++) {
$diff = $diff / $length[$i];
}
$diff = round($diff);
return $diff . " " . $strTime[$i] . "(s) ago ";
}
}
//-----------------------------------------------------------------------------
?>