PDA

Click to See Complete Forum and Search --> : Time Stamp Order


kiwis
Apr 6th, 2005, 10:31 PM
I'm adding records to my MySql DB with a time stamp IE: 1107515427

Now when I didplay my page I want it to count the time stamps and show a total for each day ie:
Apr 02 = 32
Apr 03 = 12

ect ect
anyone know how this can be done???

visualAd
Apr 7th, 2005, 02:36 AM
I would actually recommend that you use a MySql Datetime (http://dev.mysql.com/doc/mysql/en/datetime.html) data type and then use a group by query to get the data back.

You can convert a unix time stamp to a MySql date using the following:

$mysql = date("Y-m-d H:i:s", $unix_timestamp);

The following query will then return a row for each date and the umber of records corresponding to that date:

SELECT DATE_FORMAT(date_field, "%b %d") Day,Count(*) FROM table_name GROUP BY Day;