Repository URL to install this package:
|
Version:
3.12.2 ▾
|
/**
* Returns a timestamp in the format of `hours:minutes:seconds`
*/
export default function getTimeStamp() {
var noSeconds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
var date = new Date();
var hours = pad(date.getHours().toString());
var minutes = pad(date.getMinutes().toString());
var seconds = pad(date.getSeconds().toString());
return hours + ':' + minutes + (noSeconds ? ':' + seconds : '');
}
/**
* Adds zero to strings shorter than two characters
*/
function pad(str) {
return str.length !== 2 ? 0 + str : str;
}