可以帮助我在jquery中生成一个将time()转换为秒的函数
示例:1336333809 = 9分23秒?
像我发现的这个功能一样,但是它的时间是几小时function secondsToTime(secs)
{
var hours = Math.floor(secs / (60 * 60));
var divisor_for_minutes = secs % (60 * 60);
var minutes = Math.floor(divisor_for_minutes / 60);
var divisor_for_seconds = divisor_for_minutes % 60;
var seconds = Math.ceil(divisor_for_seconds);
var obj = {
"h": hours,
"m": minutes,
"s": seconds
};
return obj;
}
如果有任何解决方案,请分享:D
答案 0 :(得分:4)
原生Date
对象有什么问题?
function secondsToTime(seconds) {
var date = new Date(seconds * 1000);
var obj = {
"h": date.getHours(),
"m": date.getMinutes(),
"s": date.getSeconds()
};
}