0
guard let stamp = i.document.get("date") as? Timestamp else {
  return
}
                    
let date = stamp.dateValue()

I am trying to access the Timestamp value from Firebase Firestore to display the time and date in my app. when trying to get the date and time from the above code, the time zone is different from my local region. How can I change the timezone into UTC+5 the same which shows in my firestore?

Output that I am getting: https://i.stack.imgur.com/i7cpB.png

Timestamp stored in Firestore: https://i.stack.imgur.com/OPujH.png

jnpdx
  • 45,847
  • 6
  • 64
  • 94
Saad Sadiq
  • 37
  • 2
  • 8
  • A date is an absolute point in time. If you want to display a date in your local Timezone, use a `DateFormatter` – Paulw11 Jun 18 '21 at 07:06
  • 1
    Based on this link:https://firebase.google.com/docs/reference/js/firebase.firestore.Timestamp, FireBase timestamps are independent of time zone, just like iOS/Mac OS time stamps. If you want to display the timestamp in a particular time zone, convert it to a `Date` and use a `DateFormatter`. – Duncan C Jun 18 '21 at 11:52

0 Answers0