UNPKG

461 BJavaScriptView Raw
1/**
2 * Returns a timestamp in the format of `hours:minutes:seconds`
3 */
4module.exports = function getTimeStamp () {
5 var date = new Date()
6 var hours = pad(date.getHours().toString())
7 var minutes = pad(date.getMinutes().toString())
8 var seconds = pad(date.getSeconds().toString())
9 return hours + ':' + minutes + ':' + seconds
10}
11
12/**
13 * Adds zero to strings shorter than two characters
14 */
15function pad (str) {
16 return str.length !== 2 ? 0 + str : str
17}