I want to get Firebase Server current time as a timestamp but the value returned is wrong. The server returns a timestamp = 1535916111663 and if we convert this timestamp to date, I will be getting 30 March 50641 at 21:21:03
Note: I am using firebase Cloud function.
exports.addPost = functions.region('europe-west1').https.onRequest((request, response) => {
admin.database().ref('/.info/serverTimeOffset').once('value').then(function stv(data) {
console.log(data.val() + Date.now());
}, function (err) {
return err;
});
})
Date.now()if you want an accurate timestamp in Cloud Functions. - Doug Stevenson