I have made this formula to turn a time as string into seconds (as integer)
seperated = new Date().split(":");
seconds = seperated[0] * 60 * 60 + seperated[1] * 60 + seperated[2];
How can I do this the reverse way?
I’m not very good at mathematics 🙂
EDIT:
I tried this: (the function makeTime(…) works)
function makeTime(timestr) {
var seperated = timestr.split(":");
return seperated[0] * 60 * 60 + seperated[1] * 60 + seperated[2];
}
function timeStr(integ) {
var hours = integ / 3600;
var minutes = (integ % 3600) / 60;
var seconds = integ % 60;
return hours + ":" + minutes + ":" + seconds;
}
You can use datejs, and write a code some thing like follows
EDIT:
Or