Convert UNIX timestamp to hh:mm

I used this code in a HomeyScript card in Advanced Flow:

let time = new Date(args[0]*1000).toLocaleString(‘de-DE’,
{
hour12: false,
timeZone: ‘Europe/Berlin’,
hour: “2-digit”,
minute: “2-digit”,
day: “2-digit”,
month: “2-digit”,
year: “numeric”
});
return time;

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.

1 Like