user1189352 user1189352 - 7 months ago 70
Javascript Question

Subtracting seconds with moment.js

I have a clock i want to start at 5:00. and I just want to make a button for instance that would subtract 5 seconds so that it displays 4:55. I'm having so much difficulty with this and JS DateTime. I keep getting the error "format is not a function". What am I missing?

var dateTime = new moment(300000);

var clock = dateTime.format('m:ss'); //Displays as 5:00

//Button Click
$scope.rewindClick = function () {
clock = dateTime.diff(5000).format('m:ss');


Use moment.js subtract

dateTime.subtract(5, 'seconds').format('m:ss');