Javascript DateDiff

后端 未结 4 1775
星月不相逢
星月不相逢 2021-01-12 04:15

I am having a problem with the DateDiff function. I am trying to figure out the Difference between two dates/times. I have read this posting (What's the best way to calc

4条回答
  •  余生分开走
    2021-01-12 04:38

    Your first try does addition first and then subtraction. You cannot subtract strings anyway, so that yields NaN.

    The second trry has no closing ). Apart from that, you're calling getTime on strings. You'd need to use new Date(...).getTime(). Note that you get the result in milliseconds when subtracting dates. You could format that by taking out full days/hours/etc.

提交回复
热议问题