Files
30-seconds-of-code/snippets/js/s/get-colon-time-from-date.md
2023-05-07 16:07:29 +03:00

484 B

title, type, language, tags, cover, dateModified
title type language tags cover dateModified
Get colon time from date snippet javascript
date
string
digital-nomad-5 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'