You either want something like
floor(timestamp / 3600)
timestamp - timestamp % 3600
Reply on news.ycombinator.com