subtract time from date - moment js

前端 未结 6 1842
无人共我
无人共我 2020-12-03 03:04

I have for instance this datetime:

01:20:00 06-26-2014

and I want to subtract a time like this:

00:03:15

6条回答
  •  甜味超标
    2020-12-03 03:34

    You can create a much cleaner implementation with Moment.js Durations. No manual parsing necessary.

    var time = moment.duration("00:03:15");
    var date = moment("2014-06-07 09:22:06");
    date.subtract(time);
    $('#MomentRocks').text(date.format())
    
    
    

提交回复
热议问题