note 78544 deleted from function.date by derick
| From: | derick@php.net | Date: | Sun, 09 Dec 2007 13:38:18 +0000 |
| Subject: | note 78544 deleted from function.date by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133001@lists.php.net to get a copy of this message | ||
Note Submitter: haqpunk at mail dot google dot com
----
If you have a unix time stamp value in your DB that you would like to see the elapsed time for this
might save you some time:
<?php
if(mysql_result($result, 0, "Time_Stamp")){
$Now=strtotime(date('Y-m-d H:i:s'));
$Action=strtotime(mysql_result($result, 0, "Time_Stamp"));
## Calculate time past since status change
$dateDiff = $Now - $Action;
$Days = floor($dateDiff/(60*60*24));
$Hours = floor(($dateDiff-($Days*60*60*24))/(60*60));
$Minutes = floor(($dateDiff-($Days*60*60*24)-($Hours*60*60))/60);
$Seconds = floor($dateDiff-($Days*60*60*24)-($Hours*60*60)-($Minutes*60));
## Display in unix like time stamp format
echo str_pad($Days, 2, "0", STR_PAD_LEFT)." ".str_pad($Hours, 2, "0",
STR_PAD_LEFT).":".str_pad($Minutes, 2, "0",
STR_PAD_LEFT).":".str_pad($Seconds, 2, "0", STR_PAD_LEFT);} ?>