Reputation: 1701
How should i compare Firebase Timestamp with local device time.
let serverTIme = FIRServerValue.timestamp()
let localtime = Date()
let dbRef = FirebaseServerReference()
here is full code https://pastebin.com/4drtSZA6
Edit:
When i set timestamp in Firebase RealtimeDatabase using FIRServerValue.timestamp
it suppose to save timestamp of Server not the my device time.
In my case, it looks like it is depending on my device time. i want to check that if there is a ‘Time Difference’ in server time & my device time.
So i think that this question might not possible duplicate of Trying to convert Firebase timestamp to NSDate in Swift.
Upvotes: 5
Views: 6595
Reputation: 841
You can convert Firebase timestamp to NSDate
and then compare Date()
later on. Here is a similar question and a possible solution:
Trying to convert Firebase timestamp to NSDate in Swift
Upvotes: 1