Hello! Help Wanted

I wrote a script on js that works with slack.com api and ran into an interesting moment when I wanted to get message time (ts key)

The format of the value is approximately the same 1490647783.975041 and how then only time should be output from this, for example 10h: 00m

It is advisable to translate without third-party libraries.

    1 answer 1

    Something like this?

    var a = 1490647783.975041; var dt = new Date(a); var hours = dt.getHours(); var minutes = dt.getMinutes(); var resultTime = (hours < 10 ? '0' + hours + 'ч:' : hours + 'ч:') + (minutes < 10 ? '0' + minutes + 'м' : minutes + 'м'); console.log(resultTime);