0

I am trying to convert firebase timestamp into NSDate but continuously not able to do that. My code is like : -

if let serverTimestamp = document.data()[kSessionTimeStamp] as? TimeInterval{
    debugPrint(value)
}

it is not printing it but when I parse as [String:Any] then it successfully parsed it. but dictionary does not contain any timestamp. I am using firestore.

  • 1
    Possible duplicate of [Trying to convert Firebase timestamp to NSDate in Swift](https://stackoverflow.com/questions/29243060/trying-to-convert-firebase-timestamp-to-nsdate-in-swift) – Jayesh Thanki Feb 06 '18 at 07:06
  • I checked this not working for me – Divya Saraswati Feb 06 '18 at 09:05
  • You need to review the accepted answer. A Firebase timestamp isn't a really a timestamp. It's a trigger to tell Firebase to write timestamp data *on the server* only. You then need to read that node to get the timestamp. The code in the question is incomplete so we don't know exactly what you are doing or trying to accomplish. If you can give us more data (code) we may be able to better assist. – Jay Feb 06 '18 at 18:58

0 Answers0