Get the time from a date


PHOTO EMBED

Mon Jan 25 2021 14:11:42 GMT+0000 (UTC)

Saved by @aymanelya #javascript

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

https://medium.com/dailyjs/13-javascript-one-liners-thatll-make-you-look-like-a-pro-29a27b6f51cb