javascript - .diff is not a function on moments.js -
i try little script using moment.js, shows me how many hours , minutes (seperate) have until specific hour.
var timea = moment('08:00:00', 'hh:mm:ss').format('hh:mm:ss'); var timeb = moment('16:00:00', 'hh:mm:ss').format('hh:mm:ss'); var diffab = timea.diff(timeb); var diffhours = diffab.format('h'); var diffminutes = diffab.format('mm'); console.log('timea: ' + timea); console.log('timeb: ' + timeb); console.log('difference a-b: ' + diffab); console.log('diff hours: ' + diffhours); console.log('diff minutes: ' + diffminutes);
thats i've tried far. following error:
timea.diff not function
i not sure doing wrong here.
when call .format()
, string. you're no longer dealing moment object.
Comments
Post a Comment