Use the following SQL-query:
SELECT *, TIMESTAMPADD(HOUR, 12, DATE(TIMESTAMPADD(HOUR, -12, created))) AS grp
FROM table
ORDER BY created DESC
This puts the most recent added users on top. You can change DESC
to ASC
if you want the oldest users on top.
Also, what I've added is a grp
column. It will help you use grouping in PHP.
The result from that column is f.e. August, 24 2013 12:00:00+0000
. Whenever this value changes, you need to create a new group header in PHP.
Now, I could provide you with some code, but it's dependent on what sort of database-access you're using (mysqli_*-functions or PDO), so I won't go into much detail about that.
What I can provide is a link for you containing more information on grouping records using a while loop, which has been provided as an answer to a different question here on SO.
EDIT
To display only the number of users (and the beginning of the timeframe), you would use a different approach:
SELECT COUNT(id), TIMESTAMPADD(HOUR, 12, DATE(TIMESTAMPADD(HOUR, -12, created))) AS grp
FROM table
GROUP BY grp
ORDER BY created DESC;
To see the query in action, check out this SQL-Fiddle.