user377419
user377419

Reputation: 5009

MySQL / PHP - Time Question

In my DB I stored the time of the last page refresh in a TIME column. I want to compare the last page refresh to the current time now and find out how many 5 minuet periods have passed?

I was thinking take the last page refresh and subtract it from the current time then divide by 5. But I don't know about how things are formatted.

Help me please!

Upvotes: 0

Views: 148

Answers (1)

cichy
cichy

Reputation: 10644

SELECT *, FLOOR(((UNIX_TIMESTAMP()-time_field)/300)) AS periods FROM table

Im not sure for if UNIX_TIMESTAMP() returns correct timestamp, you will have to check it ;)
EDIT: checked it myself and its working great ;)

Upvotes: 1

Related Questions