I have linked up an app that I have made to an Firebase database.
The app sends Firebase the time as a timeIntervalSinceReferenceDate
when a button is pressed. An example of the value is - 498898978852.928.
I want this number to distinguish wether the user has pressed that same button more less than 48 hours ago.
Is there a way to measure the time period of 48 hours or should I use a different method?
I am using swift 2 and Xcode 7!
Swift 3. If you are using Swift 2, use NSDate
You are using unix timeStamp*1000 which when casted to Int is used as a timestamp, but since you are going to use it for time manipulations. use this to store your timestamp:-
Make an extension of NSDate outside your class scope
Declaration:-
Then in your .observe event firebase function use this: -
Check Condition
For further date manipulation look up :- Difference between two NSDates