Re: mysql timestamp - subtracting two times

From: Date: Mon, 03 Jul 2000 16:13:07 +0000
Subject: Re: mysql timestamp - subtracting two times
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-4519@lists.php.net to get a copy of this message
i guess you can find info. here: http://phpbuilder.com/columns/akent20000610.php3 -onur On Mon, 3 Jul 2000, Nick Riemondi wrote: > 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; > > }; > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#4519) next »