Node.js examples for String:Format
To format time string
/**// w w w . ja va 2 s.com * Valentines Plugin - Event JS * */ String.prototype.toFormatTime = function () { var sec_numb = parseInt(this); var hours = Math.floor(sec_numb / 3600); var minutes = Math.floor((sec_numb - (hours * 3600)) / 60); var seconds = sec_numb - (hours * 3600) - (minutes * 60); if (hours < 10) {hours = "0"+hours;} if (minutes < 10) {minutes = "0"+minutes;} if (seconds < 10) {seconds = "0"+seconds;} var time = hours+':'+minutes+':'+seconds; return time; };