Store time efficiently in Firebase database?
I'm just wondering if there is a way to store Time in Firebase using Swift? The reason I am asking is because I want to create an application when when a certain object is created, the object will start a timer counting down from 24 hours when it is created. When these 24 hours have elapsed, the object is deleted. I also want to show a countdown timer to show how much longer an object has remained before it is deleted.
I've tried storing hours and minutes as Integers in my database, but that doesn't seem very efficient as I have to worry about AM / PM and might have to worry about which day. I also thought about storing the date as strings, but it seems difficult in figuring out how to constantly change the string to an integer and decrease the time to show the countdown that way.
I have looked
, but I cannot save this to Firebase. Are there any tips or ideas on how you can implement this? Thank.
EDIT: Trying to save
self.firebaseRef.childByAutoId().setValue([ "individualId":individualId.text, "timeCreated": FirebaseServerValue.timestamp() ])
However, I am getting an error
'_' is not convertible to 'StringLiteralConvertible'
. I tried to see if the timestamp has any methods to turn it into a string or an integer, but couldn't find anything that I think would be useful with autocomplete.
source to share