Following code returns hours for given seconds, which is working.
<?php
$hrs = seconds_to_dezi(278280);
echo $hrs;
$filename = "test";
header("Content-type: application/vnd-ms-excel");
header("Content-Disposition: attachment; filename=$filename.xls");
function seconds_to_dezi($s) {
$n = false;
if ($s < 0) {
$n = true;
$s = -$s;
}
$h = round($s / 3600,2);
$h = number_format($h,2, ',', ' ');
$h = str_replace(".",",",$h);
if ($n == true) {
return ("-" . $h);
} else {
return ($h);
}
}
?>
Actual output in excel:- 77,3
Expected output is:- 77,30
i.e on downloading values in csv format, the trailing zero after decimal is truncated. I want to have that zero in excel.