Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/426.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 工时表计算的起点JQuery/Ajax/other_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript 工时表计算的起点JQuery/Ajax/other

Javascript 工时表计算的起点JQuery/Ajax/other,javascript,jquery,ajax,Javascript,Jquery,Ajax,我需要为时间创建一系列前端计算。我搜索了又搜索,但似乎找不到任何好的教程或模板来指引我正确的方向。我想知道是否有人可以通过以下链接做到这一点: 这就是我需要帮助才能完成的事情当用户输入时间和超时(然后输入时间2和超时2)时,我需要计算当天的总正常工作时间。 一旦我可以填充值,我就已经涵盖了所有的后端PHP/MySQL内容,但是我假设我在这里寻找的是Ajax或JQuery,我不知道如何做。有任何想法或链接指向已经完成的人吗?在本例中,我们使用类似于“08/18/2014 05:30:PM”的日期

我需要为时间创建一系列前端计算。我搜索了又搜索,但似乎找不到任何好的教程或模板来指引我正确的方向。我想知道是否有人可以通过以下链接做到这一点:

这就是我需要帮助才能完成的事情当用户输入时间和超时(然后输入时间2和超时2)时,我需要计算当天的总正常工作时间。


一旦我可以填充值,我就已经涵盖了所有的后端PHP/MySQL内容,但是我假设我在这里寻找的是Ajax或JQuery,我不知道如何做。有任何想法或链接指向已经完成的人吗?

在本例中,我们使用类似于“08/18/2014 05:30:PM”的日期字符串创建日期时间

从该页面,这是一个从其中两个字段中获取正确日期时间的示例。
var-time=newdate($('fdate1').val()+“”+$('fti2-1').val())
。fdate1包含对日期的引用,fti2-2包含对时间的引用

然后可以使用JS中内置的DateTime函数。
参考:

需要注意的是:

.getTime()函数用于返回自1970年1月1日午夜以来的毫秒数。 你可以用这个来计算两个日期的差异

.getDate()将返回DateTime中当前月份的日期

.setDate()将根据DateTime中的当前月份设置日期(以下示例)。传入一个负数或一个超出当前DateTime中月份天数的数字将使DateTime提前到下一个月,并根据溢出的天数确定正确的天数

同样的逻辑也适用于分钟、秒等

示例:

function differenceInMinutes(timeIn, timeOut) {
  return (timeOut.getTime() - timeIn.getTime()) / 1000 / 60;
  //1000 ms per sec. 60 sec per min
}

function twoWeeksAgo() {
  //gets new DateTime set to current time
  var date = new Date();
  //We get the current day of the month (at time of this post it will return 19).
  //Subtract 14 from that and set that to the current day.
  date.setDate(date.getDate() - 14);
  return date;
  //A value causing the date to be less then 0 (in this case 20 or greater) will cause the date to push back the the last month.
}

你需要用约会时间做事情吗?比如JavaScript日期?现在还不清楚您是在寻找DateTime计算方面的帮助,还是在jQuery/Ajax方面的帮助,或者两者兼而有之。这是我需要帮助的数学部分。对不起,我编辑了原始帖子以澄清这一点。