List hits per hour from a MySQL table
Posted
by Axel
on Stack Overflow
See other posts from Stack Overflow
or by Axel
Published on 2010-04-20T23:14:57Z
Indexed on
2010/04/20
23:23 UTC
Read the original article
Hit count: 273
I am trying to work out the hits per hour from a database. Data basically is stored as follows (with other columns) :
Table Name: Hits
============================
VisitorIP TIMESTAMP
----------------------------
15.215.65.65 123456789
I want to display total hits per hour (within the last 6 hours ) including the hours that has no hits. Example of the output:
// Assuming now : 21:00
21:00 - 0 hits
20:00 - 1 hits
19:00 - 4 hits
18:00 - 0 hits
17:00 - 2 hits
16:00 - 3 hits
i would love to get the data as array, Please note that the stored date is in UNIX time stamp format. and there may be some hours without any hits!
Thanks
© Stack Overflow or respective owner