Log time from date

PHOTO EMBED

Wed Jan 05 2022 11:29:48 GMT+0000 (UTC)

Saved by @desiboli ##javascript ##js

const timeFromDate = date => date.toTimeString().slice(0, 8);
console.log(timeFromDate(new Date(2021, 0, 10, 17, 30, 0))); 
// Result: "17:30:00"
content_copyCOPY

We can log time, in the format hour::minutes::seconds from a given date.

https://blog.devgenius.io/15-javascript-codes-you-will-always-need-e8569903dd1