I was trying from last night to create something useful for myself instead of just changing codes and playing with it!
so I decided to make a script that can take an input of large number of seconds, and convert them to a time !
like if we take for example 90050 seconds, then It will be
1 day, 1:00:50
Second Example : 85000 seconds
will be
23:36:39
so I tried yesterday and today with no success !
I could not find the way to solve this problem !!
here is my code!
<?php
error_reporting(E_ALL & ~ E_NOTICE);
function caltime($time) // $time will be in seconds !
{
$second = round($time);
// day sec
$dSec = 86400;
// hour sec
$hSec = 3600;
// minute sec
$mSec = 60;
$mins = 60;
$hrs = 24;
if ($second > $dSec) {
$second = $second / $dSec;
if ($second > $hrs) {
$second = $second / $hrs;
}
else
{
if($second > $mins)
{
}
}
} else {
if ($second > $hrs) {
$second = $second / $hrs;
}
}
}
if (isset($_POST['submit'])) {
$sec = $_POST['sec'];
echo caltime($sec);
} else {
echo '<form action="" method="post">
how many? <input type="text" name="sec" />
<br />
<input type="submit" name="submit" value="Calculate" />
</form>';
}
?>
any suggestions??
This post has been edited by samoi: 05 March 2009 - 12:34 AM

New Topic/Question
Reply




MultiQuote









|