javascript - calculate time difference in node.js -


i want calculate difference between current time , date recuperate program. unfortunalety, second date on iso format ie. in :

date2 = "2015-07-16t16:33:39.113z" 

i want calculate difference between date2 , current time , display difference " 0h 53min 10s" example. how can in node.js please?

try using moment. get current time via now() function call , manipulate dates framework (use diff()).

var moment = require('moment');  date2 = "2015-07-16t16:33:39.113z"  var = moment(date2, "yyyy-mm-dd't'hh:mm:ss:sssz"); var = moment();  var diff = moment.duration(then.diff(now)); if (diff < 0) {     diff = math.abs(diff); } var d = moment.utc(diff).format("hh:mm:ss:sss"); console.log("difference: " + d); 

for reference, see get time difference between 2 datetimes


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -