【问题标题】:Using the users inputed date when finding the difference between times在查找时间差时使用用户输入的日期
【发布时间】:2018-11-27 05:47:57
【问题描述】:

我已经搜索并看到了如何找到时间之间的差异,但是当我这样做时如何使用用户输入的日期?任何帮助表示赞赏。谢谢。

const activity = $('#activity').val();
const startValue = $('#start-time').val();
const endValue = $('#end-time').val();
const date = $('#date').val();
const timeStart = new Date("date" + startValue).getHours();
const timeEnd = new Date("date" + endValue).getHours();
const inBetween = timeEnd - timeStart;

【问题讨论】:

标签: javascript


【解决方案1】:

你可以这样做......

var startDate = new Date(startValue); // start time
var endDate = new Date(endValue); //end tme

var diff = endDate - startDate;

Here你可以找到更详细的答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多