Kavin Kumar Arumugam
Kavin Kumar Arumugam

Reputation: 1832

Firebase Firestore Timestamp to Date Issue

After upgrading my code to Swift 5, Firestore is returning NSDate as FIRTimestamp. When I am trying to receive it as Date it throwing error as:

Could not cast value of type 'FIRTimestamp' (0x107aab8c0) to 'NSNumber' (0x10b8fbe00).

How to fix this issue?

Upvotes: 3

Views: 1456

Answers (1)

Kavin Kumar Arumugam
Kavin Kumar Arumugam

Reputation: 1832

Here is the code which is used to get Timestamp value from Firestore and convert it into NSDate

let timestamp: Timestamp = (filteredtotalArray[indexPath.row] as AnyObject).value(forKey: "requestedDate")! as! Timestamp
let RequestedDate = timestamp.dateValue()

Upvotes: 7

Related Questions