The detritus of a Button Monkey

14 Jan

Time stamps

My project involves php and mysql. One element of the project is looking at the time in takes for an event to occur. At the moment, I’m using timestamps to record the time. I need to subtract the timestamps to produce the time difference.

This is the solution taht is working for me so far,

SELECT UNIX_TIMESTAMP(result_time)-UNIX_TIMESTAMP(request_time)
FROM tables
WHERE condition

This produces the time in seconds which I can later format to look nice.

P.S. I have altered the select statement so it produces the average like so:

AVG(UNIX_TIMESTAMP( result_time ) – UNIX_TIMESTAMP( request_time ))

Leave a Reply

You must be logged in to post a comment.

© 2017 The detritus of a Button Monkey | Entries (RSS) and Comments (RSS)

Design by Your Index - Powered By Wordpress