Files
30-seconds-of-code/snippets/get-colon-time-from-date.md
Angelos Chalaris 61200d90c4 Kebab file names
2023-04-27 21:58:35 +03:00

483 B

title, tags, cover, firstSeen, lastUpdated
title tags cover firstSeen lastUpdated
Get colon time from date date,string digital-nomad-5 2018-01-13T17:14:48+02:00 2020-10-19T22:49:51+03:00

Returns a string of the form HH:MM:SS from a Date object.

  • Use Date.prototype.toTimeString() and String.prototype.slice() to get the HH:MM:SS part of a given Date object.
const getColonTimeFromDate = date => date.toTimeString().slice(0, 8);
getColonTimeFromDate(new Date()); // '08:38:00'