note 82260 added to function.time
| From: | binupillai2003 at yahoo dot com | Date: | Thu, 03 Apr 2008 05:10:33 +0000 |
| Subject: | note 82260 added to function.time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137878@lists.php.net to get a copy of this message | ||
Calculate time difference(24 hours system)
<?php
//Author Binu.v.Pillai
function diffTime($bigTime,$smallTime)
{
//input format hh:mm:ss
list($h1,$m1,$s1)=split(":",$bigTime);
list($h2,$m2,$s2)=split(":",$smallTime);
$second1=$s1+($h1*3600)+($m1*60);//converting it into seconds
$second2=$s2+($h2*3600)+($m2*60);
if ($second1==$second2)
{
$resultTime="00:00:00";
return $resultTime;
exit();
}
if ($second1<$second2) //
{
$second1=$second1+(24*60*60);//adding 24 hours to it.
}
$second3=$second1-$second2;
//print $second3;
if ($second3==0)
{
$h3=0;
}
else
{
$h3=floor($second3/3600);//find total hours
}
$remSecond=$second3-($h3*3600);//get remaining seconds
if ($remSecond==0)
{
$m3=0;
}
else
{
$m3=floor($remSecond/60);// for finding remaining minutes
}
$s3=$remSecond-(60*$m3);
if($h3==0)//formating result.
{
$h3="00";
}
if($m3==0)
{
$m3="00";
}
if($s3==0)
{
$s3="00";
}
$resultTime="$h3:$m3:$s3";
return $resultTime;
}
?>
----
Server IP: 203.199.69.133
Probable Submitter: 125.17.241.229
----
Manual Page -- http://www.php.net/manual/en/function.time.php
Edit -- https://master.php.net/note/edit/82260
Del: integrated -- https://master.php.net/note/delete/82260/integrated
Del: useless -- https://master.php.net/note/delete/82260/useless
Del: bad code -- https://master.php.net/note/delete/82260/bad+code
Del: spam -- https://master.php.net/note/delete/82260/spam
Del: non-english -- https://master.php.net/note/delete/82260/non-english
Del: in docs -- https://master.php.net/note/delete/82260/in+docs
Del: other reasons-- https://master.php.net/note/delete/82260
Reject -- https://master.php.net/note/reject/82260
Search -- https://master.php.net/manage/user-notes.php