I'm trying to develop google assistant using node.js firebase cloud functions and Dialogflow so when I was trying console.log to test what it looks like when I deploy everything works just fine but when I test it on a simulator the time in the sentence doesn't match my local time ex. it says it's 11:00 AM while in my country it's 18:00. can anyone tell me how to fix it?
If you use Cloud Functions for Firebase, the webhook time is going to be set to the GMT timezone (+0). This is useful in some cases for consistency, with the downside that it won't guarantee to reflect the client.
In our recently published location sample we use a new timezone
field in order to get the client timezone. With this, and the timezone in GMT, you can use a library like spacetime to get the time local to the user.
const spacetime = require('spacetime');
app.handle('location_granted', (conv) => {
const {id} = conv.request.device.timeZone;
let localTime = spacetime(new Date());
localTime = localTime.goto(id); // Set timezone
conv.add(`The Local Time is ${localTime.format('{time}')}.`)
});