'How to diff two HH:mm:ss formatting in moment

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.

In C# , which works fine.

 var dayDuration = new TimeSpan(00, 00, 00).Subtract(Convert.ToDateTime("2019-02-01 18:00:00").TimeOfDay);
            Console.WriteLine(dayDuration);

And I have tried this .

let n = moment.duration(moment("00:00:00", "HH:mm:ss").diff(moment("18:00:00", "HH:mm:ss")));

console.log(n);

enter image description here

I need below format. 18:00:00

http://jsfiddle.net/5103y2du/4/

Atlast I have found solution but the solution is not good.

let n = moment.duration(moment("00:00:00", "HH:mm:ss").diff(moment("18:00:00", "HH:mm:ss")));

working fine

let z = n.hours();
let y = n.minutes();
let u = n.seconds();
console.log(z+":0"+y+":0"+u);

-- Not working

Need the same by using moment

console.log(moment(n.hours).format("hh:mm:ss"));


Solution 1:[1]

Subtracting 18 hours from 00:00:00 would be 06:00:00, no? moment(moment("00:00:00", "HH:mm:ss")).add(18, 'hours').format("HH:mm:ss") returns 18:00:00

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 stever