Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase timestamp in php

Which method to use in php to generate firebase timestamp, which is equally to firebase.serverValue.timestamp?

I have tried using time(), apparently it's wrong format.

like image 783
Basit Avatar asked Dec 07 '22 20:12

Basit


1 Answers

If you are using Google SDK for (Firebase / Firestore), you can use the following :

use Google\Cloud\Core\Timestamp;

// ....

$stamp = new Timestamp(new DateTime());

Then store $stamp into database.. so you will get a field similar to this

enter image description here

like image 174
MujtabaFR Avatar answered Dec 10 '22 23:12

MujtabaFR