Work with a time span in Javascript

后端 未结 7 596
感动是毒
感动是毒 2020-11-30 05:53

Using Date.js already, but can also use another library if necessary.

Not sure what is the best way to work with time deltas. Specifically, I want to display the tim

相关标签:
7条回答
  • 2020-11-30 06:33

    Moment.js provides such functionality:

    http://momentjs.com/

    It's well documented and nice library.

    It should go along the lines "Duration" and "Humanize of API http://momentjs.com/docs/#/displaying/from/

     var d1, d2; // Timepoints
     var differenceInPlainText = moment(a).from(moment(b), true); // Add true for suffixless text
    
    0 讨论(0)
提交回复
热议问题