Chat messages ordered by date, how?

Hi!, I’m using couchbase lite (with couchbase server) to make a chat app. My problem is with messages order! Chat messages have to be ordered by date. But how? At first, I was ordering messages by document Id, but this is not incremental (it’s a uuid) so I can’t use document Id to perform queries ordering by this attribute. So, every message should have a timestamp, I think. But how I get the correct timestamp? Clients (mobile devices) doesn’t have the same exact date, they could have wrongs local dates, so they shouldn’t set the timestamps, right? I think it’s responsability to the server side to set the correct date for every message… But how can I do that? Any tips? Thanks you very much.

I think we have the same question .
I am thinking, may be we can make device to sync time to CB server when device is online(before create message in local couchbase-lite database),then app can use local time.