Format Colon Time from Date

This commit is contained in:
Michael Goldspinner
2018-01-11 20:46:18 -05:00
parent 5fe2b016ee
commit 49ddcb5e63

View File

@ -0,0 +1,11 @@
### Format Colon Timestamp from Date (12 hour format)
Utilizes to12Hour() to transform date.getHours() to 12 hour format and toDigits to maintain double digits for time integers. Formats integers from given date object into a colon time representation.
```js
let toColonTime12 = ( date ) => {
let times = [ to12Hour(date.getHours()), date.getMinutes(), date.getSeconds() ];
return times.map( t => setDigits(t, 2, 1) ).join(":");
}
// toColonTime12(new Date()) -> "08:38:00"
```