|
|
|
<?php
Function elapsedtime ($stop, $start) {
$id2 = substr($stop, 0, 1);//day when stop
$id1 = substr($start, 0, 1);//day when start
$a_1 = substr($stop, 2, 2); //hour when stop
$b_1 = substr($start, 2, 2); //hour when start
$a_2 = substr($stop, 5, 2); //minutes when stop
$b_2 = substr($start, 5, 2); //minutes when start
$a_3 = substr($stop, 8, 2); //seconds when stop
$b_3 = substr($start, 8, 2); //seconds when start
if (b_1 > $a_1 && $b_2 > $a_2 && b_3 > a_3)
{
$ide= $id2 - $id1 - 1;
$a = $a_1 - $b_1 + 23;
$b = $a_2 - $b_2 + 59;
$c = $a_3 - $b_3 + 60;}
else if ($b_1 > $a_1 && $b_2 > $a_2)
{
$ide=$id2-$id1 - 1;
$a = $a_1 - $b_1 + 23;
$b = $a_2 - $b_2 + 60;
$c = $a_3 - $b_3;}
else if ($b_1 > $a_1)
{
$ide=$id2 - $id1 - 1;
$a = $a_1 - $b_1 + 24;
$b = $a_2 - $b_2;
$c = $a_3 - $b_3;}
else if ($b_1 > $a_1 && $a_3 > $b_3)
{
$ide=$id2-$id1 - 1;
$a = $a_1 - $a_2;
$b = $a_2 - $b_2 - 1;
$c = $a_3 - $b_3 + 60;}
else if ($a==0 && $b_3 > $a_3) {
$ide= $id2-$id1;
$a = $a_1 - $b_1;
$b = $a_2-$b_2 - 1;
$c = $a_3 - $b_3 + 60;}
else if($b_2 > $a_2) {
$ide= $id2-$id1;
$a = $a_1 - $b_1 - 1;
$b = $a_2 - $b_2 + 60;
$c = $a_3 - $b_3; }
else if($b_3 > $a_3) {
$ide= $id2-$id1;
$a = $a_1 - $b_1;
$b = $a_2 - $b_2 - 1;
$c = $a_3 - $b_3 + 60; }
else if (($b_2 > $a_2) && ($b_3 > $a_3)) {
$ide= $id2-$id1;
$a = $a_1 - $b_1 - 1;
$b = $a_2 - $b_2 + 59;
$c = $a_3 - $b_3 + 60; }
else {
$ide= $id2 - $id1;
$a = $a_1 - $b_1;
$b = $a_2 - $b_2;
$c = $a_3 - $b_3;}
return $ide*24*3600 + $a*3600+ $b*60 + $c;
}
echo" the elapsed time for start 0:23:35:59 and stop: 1:10:36:53 is ";
echo elapsedtime ('1:10:36:53','0:23:35:59');
echo" secs";
echo"<br>";
echo" the elapsed time for start 0:23:35:59 and stop: 1:23:35:59 is ";
echo elapsedtime ('1:23:35:59','0:23:35:59');
echo" secs";
echo"<br>";
echo" the elapsed time for start 0:54:26:31 and stop: 0:55:36:28 is ";
echo elapsedtime ('0:55:36:28','0:54:26:31');
echo" secs";
?> |
|
| A Timing Class Categories : PHP, PHP Classes, Date Time | | | Finding the day of the week for a specific date.
Categories : PHP, Databases, MySQL, Date Time | | | A wrapper function to format dates coming from a databases with the
same syntax as PHP's date() function. Categories : Date Time, Databases, PHP | | | pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes | | | A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function. Categories : PHP, PHP Classes, Calendar, Date Time | | | PHP Round Clock - Must have Gif support to use this. Categories : PHP, Date Time, Graphics | | | A simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed. Categories : Date Time, PHP, Complete Programs, Calendar | | | Open and Close your website in fixed times . Categories : PHP, PHP Classes, Cron, Date Time | | | mysql date/time converters Categories : PHP, MySQL, Databases, Date Time | | | Creates three SELECT form fields: Month, Day, and Year. You give it a string which will be used to make the name for the three fields, and a number of seconds to use as the default date. If you give it blank for this value, the current date is used. Categories : HTML and PHP, PHP, Date Time | | | If you want to create select buttons featuring current date this example will show you how... Categories : Date Time, HTML and PHP, PHP | | | Example of using the pcCalendar class, article 1468 on weberdev.com. Calendar example. Categories : PHP, Date Time, PHP Classes, Calendar | | | calculus of the eastersunday Categories : BC math, PHP, Date Time, Databases | | | Functions used to define a schedule of holidays. Can define non-fixed holidays (eg. 3rd sunday of June). Categories : Calendar, Date Time, PHP | | | Monthly and Daily Upcoming Events calendar. Categories : Date Time, PostgreSQL, PHP, Calendar, Databases | |
|
|
|