I found a lot of ways, but I solved it easier...
If we have a table "tab" with a "Dates" field:
SELECT case
when FROM_UNIXTIME(Dates, '%i')<=29 then FROM_UNIXTIME(Dates, '%Y/%m/%d %H:00:00')
when FROM_UNIXTIME(Dates, '%i')>=30 then FROM_UNIXTIME(Dates, '%Y/%m/%d %H:30:00')
end as datka,
COUNT(*)
FROM tab
group by datka
Similarly, it can be grouped by 15 minutes or any other interval.
P.S. If time is in datetime instead of timestamp, then DATE_FORMAT can be used instead FROM_UNIXTIME.