mysql timestamp - subtracting two times

From: Date: Mon, 03 Jul 2000 14:57:37 +0000
Subject: mysql timestamp - subtracting two times
Groups: php.general 
Request: Send a blank email to php-general+get-4502@lists.php.net to get a copy of this message
Hey, I'm trying to find a useful way to get the amount of time that passed between two mysql timestamps (hrs:mins). Anyone have any ideas? Obviously you can't just subtract them. Here is some code I'm using to display the timestamp in a nice fashion. Basically I'm needing to replace the "$time = $timestamp - $lastone;" with something useful. Thanks! Nick Riemondi --------------------------------------- function mysql_to_epoch($datestr) { ereg("([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})",$datestr, $regs); return date("D, j M Y, h:i:s a",mktime($regs[4],$regs[5], $regs[6], $regs[2],$regs[3], $regs[1])); } ##################### $result = my_query("select name,time_ from time"); while (list($name,$timestamp) = mysql_fetch_row($result)) { print mysql_to_epoch($timestamp); $time = $timestamp - $lastone; print " <br> $timestamp<br> $time<br> <br><br> "; $lastone = $timestamp; };

« previous php.general (#4502) next »