简体   繁体   中英

How to get the time zone

I am trying to get the time for my echo skill. I got the time, but it is in the wrong time zone. how do I make it to where the time adjusts to the time zone?

Here is my code:

var d = new Date(); 
var dateHour = d.getHours();
var dateMinutes = d.getMinutes();

var nonTime = dateHour + ":" + dateMinutes;
var dateTime = nonTime

var speechOutput = "This is a test " + today + ' ' + dateTime ;
this.emit(':tellWithCard', speechOutput, today); },

The time that I posted this is 10:16, here is what my log displays:

   "outputSpeech": {
  "type": "SSML",
  "ssml": "<speak> This is a test September 5, 2017 3:16 </speak>"

Momentjs is your friend. You can pass in your time zone and get the current time in that zone.

https://momentjs.com/timezone/docs/

All scripts run in UTC timezone. You need to specify the timezone of the user.

在 python 中使用 print(time.tzname)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM