note 57110 deleted from language.types.float by cmb
| From: | cmb@php.net | Date: | Mon, 11 Jul 2016 22:04:32 +0000 |
| Subject: | note 57110 deleted from language.types.float by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-205971@lists.php.net to get a copy of this message | ||
Note Submitter: TRI0N
----
Here is a simple formula to break down a number and get rid of the decimal values. I built this to
take a number in seconds and convert it to a readable value for Server Uptimes.
<?php
$day = floor(($uptime / 86400)*1.0) ;
$calc1 = $day * 86400 ;
$calc2 = $uptime - $calc1 ;
$hour = floor(($calc2 / 3600)*1.0) ;
if ($hour < 10) {
$hour = "0".$hour ;
}
$calc3 = $hour * 3600 ;
$calc4 = $calc2 - $calc3 ;
$min = floor(($calc4 / 60)*1.0) ;
if ($min < 10) {
$min = "0".$min ;
}
$calc5 = $min * 60 ;
$sec = floor(($calc4 - $calc5)*1.0) ;
if ($min < 10) {
$sec = "0".$sec ;
}
$uptime2 = $day." Days, ".$hour.":".$min.":".$sec ;
?>
Place this where you want the results to be seen:
<?php echo $uptime2 ; ?>
For a Value of 1455587 seconds the results will show as followed:
16 Days, 20:19:47
Enjoy