Display messages in a chat with the date it was created

Good afternoon!
Please advise how to implement the following functionality. I have a chat room where users communicate. At the top of each message should display the time it was sent. The first message which is sent in the current day should have the date of sending (day and month) and time, and all others only time.
How can this be implemented?
I would be grateful for answers.

1 Like

Do you store the messages as a separate data type?

In this case, you can use the created date field. For the issue of how to display it, it depends on how much the data volume can usually be?

For example, you can group the messages into the field created date and find the minimum date in each day, and then change the display mode for that message with a condition.

But this was an example,

According to the database structure and amount of data, the appropriate method should be chosen.

This topic was automatically closed after 70 days. New replies are no longer allowed.