0

I am new to nodejs, and I am trying to get the difference between 2 times, but I get a different value. here is my code :

         var now = moment(Suivi.FI);
         var then = moment(Suivi.DI);
         var TA = moment(moment.duration(then.diff(now))).format("hh:mm");

as a result i get:

sql": "Insert into suivi(date, equipement, project, shift, description, Action, user, DA, DI, FI,TA) values('','','','','','','','','','','12:00')"

I tried to test with a simple date but I got the same value. what am I missing? what should I do.?

Dino
  • 7,779
  • 12
  • 46
  • 85
so hyun
  • 47
  • 1
  • 8
  • 1
    Possible duplicate of [Moment JS Subtract method returns 12 hour difference when there is only zero hour left](https://stackoverflow.com/questions/33998399/moment-js-subtract-method-returns-12-hour-difference-when-there-is-only-zero-hou) – Milan Velebit Aug 20 '19 at 09:49

1 Answers1

0

you can use .format("hh:mm")

for simple time differnce:

var TA = now.diff(then);

this will give you more flexibility for formating (see docs):

var TA = moment.duration(now.diff(then));