When you end up sending a message to your server, just add that specific time. new Date().getTime() will provide you with a value that you can use to compare with the datetime of your server. If this is, for example, after 2 hours, then just set the time for sending the message after 2 hours.
So, send the time when the message was sent by the user, and the time when it was sent.
source share