let dayDuration = "23:59:59";
let anotherhour ="04:00:00";
moment.duration(moment(dayDuration, "hh:mm:ss").diff(anotherhour));
如何在循环中增加先前的值:
假设第一次迭代持续时间值为 10,第二次迭代持续时间值为 30,它应该添加为 40。
hasEvnets.map(x=>{
var dayDuration = x.startTime;
var anotherHour=x.endTime;
var remainingtime+= moment.duration(moment(dayDuration, "hh:mm:ss").diff(anotherhour));
});
和
moment(moment("00:00:00", "HH:mm:ss").diff(moment("18:00:00", "HH:mm:ss"))).format("HH:mm:ss");
moment(moment("00:00:00", "HH:mm:ss").diff(moment("18:00:00", "HH:mm:ss"))).utc().format("HH:mm:ss"); -06:00:00
which produces 00:00:00 as o/p but i need -18:00:00 how to do that formatting.
在 C# 中,效果很好。
var dayDuration = new TimeSpan(00, 00, 00).Subtract(Convert.ToDateTime("2019-02-01 18:00:00").TimeOfDay);
Console.WriteLine(dayDuration);
我已经试过了。
让 n = moment.duration(moment("00:00:00", "HH:mm:ss").diff(moment("18:00:00", "HH:mm:ss")));
控制台.log(n);
我需要以下格式。18:00:00
http://jsfiddle.net/5103y2du/4/
Atlast 我找到了解决方案,但解决方案并不好。
让 n = moment.duration(moment("00:00:00", "HH:mm:ss").diff(moment("18:00:00", "HH:mm:ss")));
工作正常
let z = n.hours();
let y = n.minutes();
let u = n.seconds();
console.log(z+":0"+y+":0"+u);
-- 不工作
使用时刻需要相同
console.log(moment(n.hours).format("hh:mm:ss"));