Postgres can round (truncate) timestamps using the date_trunc function, like this:
date_trunc(\'hour\', val)
date_trunc(\'minute\', val)
I\
Full query for those wondering (based on @DNS question):
Assuming you have orders and you want to count them by slices of 5min and shop_id:
SELECT date_trunc('hour', created_at) + date_part('minute', created_at)::int / 5 * interval '5 min' AS minute
, shop_id, count(id) as orders_count
FROM orders
GROUP BY 1, shop_id
ORDER BY 1 ASC