lundi 1 janvier 2018

Inject a date into new entry in firebase db

My issue is to inject an actual date when push a data into firebase db.

When user registers himself, following code is being executed:

firebase.database().ref('users').push().set(userData);

Everything works well. However, I would like to display in user profile the date when he created his account.

I could do it just with pushing new Date() with user data to db, but it will fail if user has an incorrect date on his computer. I would prefer to use actual date coming from server (or firebase?).

Q: How to inject actual date into firebase entry?

Q2: Is there any date service/function in firebase, which will provide actual date?

Thanks!




Aucun commentaire:

Enregistrer un commentaire