I am working on getting JSON data from tvgids.nl, but the start_time and end_time is returned as a UNIX timestamp.
I want to convert this to “hh:mm”, so I need to make this kind of calculation:
So something like this (MS Excel example): UNIX_TIMESTAMP/86400000+DATE(1970,1,1)
How can I do this?
EDIT: I would like to use the time in another flow to turn on my TV and switch to the correct channel.
Your link example based on Excel format functions which are not usable for homey.
I am now testing this solution (a HomeyScript with an argument):
…which returns the UNIX timestamp in a hh:mm string.
FYI, that will start failing in a few months time when DST becomes active.
The 60x60x1e3 is not for DST, but for a “timezone offset”.
Date.toISOString returns a time in UTC, and I need UTC+1.
getTimezoneOffset() returns 0, where I would expect it to return +1 hour.
I used this code in a HomeyScript card in Advanced Flow:
let time = new Date(args*1000).toLocaleString(‘de-DE’,
Adjust the locale (de-DE) and the timezone to yours.
You can adjust the parameters of toLocaleString to get only the hh:mm - or split the result into date and time.
Unless DST is in effect and your timezone offset becomes 2 hours.