Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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');
}
like image 538
user1189352 Avatar asked Sep 19 '25 16:09

user1189352


1 Answers

Use moment.js subtract http://momentjs.com/docs/#/manipulating/subtract/

dateTime.subtract(5, 'seconds').format('m:ss');
like image 119
Marcelo Risse Avatar answered Sep 21 '25 07:09

Marcelo Risse