I am trying to figure out how I can get the duration between two dates either with or without momentjs.
我试图弄清楚如何使用或不使用momentjs来获得两个日期之间的持续时间。
here is the code I have implemented in the table using bootstrap-table
这是我使用bootstrap-table在表中实现的代码
<tr>
<th id="startedat" data-field="StartedAt" data-formatter="dateFormatter">Started At</th>
<th id="finishedat" data-field="FinishedAt" data-formatter="dateFormatter">Finished At</th>
<th data-formatter="duration">Duration</th>
in my Javascript I would then use
在我的Javascript中,我会使用
function dateFormatter(value) {
return moment().format("dddd, MMMM Do YYYY, h:mm:ss a");
but how to do I now set up the function for duration? any ideas
但是我现在如何设置持续时间的功能?有任何想法吗
1 个解决方案
#1
2
with moment You can use .diff
与时刻你可以使用.diff
var a = moment([2007, 0, 29]);
var b = moment([2007, 0, 28]);
a.diff(b) // 86400000
#1
2
with moment You can use .diff
与时刻你可以使用.diff
var a = moment([2007, 0, 29]);
var b = moment([2007, 0, 28]);
a.diff(b) // 86400000