Local time in HomeyScript

iotnerd
Fri, 07 Aug 2020 07:04:53 +0000
Questions & Help

Is this really the best way to get the local time in HomeyScript or am I missing something?

const sys = await Homey.system.getInfo();
console.log('sys datetime', sys.date)
const datetime = new Date(sys.date)
datetime.setMinutes(datetime.getMinutes() - new Date().getTimezoneOffset())
console.log('local datetime', datetime)

sys datetime 2020-08-07T07:01:36.101Z
local datetime 2020-08-07T09:01:36.101Z

38 posts - 11 participants