Basit Basit - 10 days ago 8
PHP Question

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

, apparently it's wrong format.


public static final Map TIMESTAMP

A placeholder value for auto-populating the current timestamp (time since the Unix epoch, in milliseconds) by the Firebase Database servers. Doc Link

As it reads in the documentation it's in millis. The actual definition of timestamp is in seconds but, anyway to get the actual timestamp in millis in PHP you have to


Edit: to get millis from microseconds (returned by microtime()) you have to:

$timeparts = explode(" ",microtime());
$currenttime = bcadd(($timeparts[0]*1000),bcmul($timeparts[1],1000));
echo $currenttime;