Php > Date Time sample source codes
A function that will calculate elapsed time in d-hh-mm-ss format.
A function that will calculate elapsed time in d-hh-mm-ss format. $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"
"; 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"
"; 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"; ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage