I have two times, let say:
t1= \'05:34:01\' ;
t2= \'20:44:44\' ;
I want two evaluate difference between these two times in same format. Li
Highly recommend you include moment.js in your project if you need to handle time.
Example:
var t1 = moment('05:34:01', "hh:mm:ss");
var t2 = moment('20:44:44', "hh:mm:ss");
var t3 = moment(t2.diff(t1)).format("hh:mm:ss");
Working jsFiddle
To install moment.js in Node.js, simply do:
npm install moment
(or for a global install sudo npm -g install moment
)
And then in your Node.js, include it like so:
var moment = require('moment');
Edit: For 24h clock, change hh
to HH
.