【发布时间】:2020-02-05 05:48:30
【问题描述】:
我需要将秒转换为HH:mm:ss:ms 格式。我的功能如下。
function formatTime(time) {
var rootDate = new Date(new Date(2018, 1, 1, 0, 0, 0).setSeconds(time));
console.log(rootDate);
return rootDate;
}
formatTime(100);
上述函数给出以下输出,
Thu Feb 01 2018 00:01:40 GMT+0530 (India Standard Time)
你可以看到,它返回时间为00:01:40。但我也需要毫秒部分。比如00:01:40:00我该怎么做。
我需要返回数据时间对象
【问题讨论】:
标签: javascript jquery datetime milliseconds