Greetings, there is something like a forum, there are certain topics in it and messages in them, there is a time for sending a message (unixtimestamp). It is necessary to break these messages into groups by day. It is clear that you need to compare the time of dispatch with the time of the beginning and end of the day, but where do you get these times? or maybe there is some other, more beautiful way.

    1 answer 1

    SQL:

    SELECT FROM_UNIXTIME(date_field, '%Y-%m-%d') 

    PHP (using handy PDO functionality that allows you to group lines ):

     $sql = "SELECT FROM_UNIXTIME(date_field, '%Y-%m-%d'), * FROM forum"; $data = $pdo->query($sql)->fetchAll(PDO::FETCH_GROUP); 

    returns an array of which keys will be the dates, and the values ​​- all the records for these dates

    • not a bad decision, it's a pity that the project is still mysql .. - VK