I have for instance this datetime:
01:20:00 06-26-2014
and I want to subtract a time like this:
00:03:15
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())