I was just wondering, is there a means to store Time in Firebase using Swift? The reason why I ask is because I want to make an application that when I create a particular object, the object will start a timer that counts down from 24 hours of when it was created. When those 24 hours expire, the object is deleted. I also want to show a count down timer to show how much longer the object has left before it's deleted.
I tried storing the hour and minutes as Integers into my database but that doesn't seem very efficient since I have to worry about AM/PM, and possibly have to worry about what day it is. I was also thinking about storing the date as a string but that seems arduous in figuring out how to constantly change the string to an integer and decrement the time to show the countdown that way.
I've looked into the FirebaseServerValue.timestamp()
but I can't seem to store that into Firebase. Are there any tips or ideas on how one would implement this? Thanks.
EDIT: Attempt to store FirebaseServerValue.timestamp()
into Firebase:
self.firebaseRef.childByAutoId().setValue([
"individualId":individualId.text,
"timeCreated": FirebaseServerValue.timestamp()
])
However I get an error saying that '_' is not convertible to 'StringLiteralConvertible'
. I tried to see if timestamp had any methods to turn it into a String or an Integer but couldn't find anything that I thought would be useful with the autocomplete.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…