为什么手动设置时间与当前时间不同
Why is a manual setup time different to the current Time
手动设置时间和当前设置时间的区别在哪里?
根据此语法:
new Date(year, month, day, hours, minutes, seconds, milliseconds)
这应该没有什么区别。
var now = new Date();
var alarmTime = new Date(now.getFullYear(), now.getMonth(), now.getDay(), now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds());
document.write(alarmTime.getTime() == now.getTime());
您调用了错误的方法。它是now.getDate()
而不是now.getDay()
。
now.getDay()
将返回当前日期(5)now.getDate()
将返回当前日期(29)。
固定:
var now = new Date();
var alarmTime = new Date(now.getFullYear(), now.getMonth(),now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds(),now.getMilliseconds());
document.write(alarmTime.getTime() == now.getTime());
getMonth()方法根据当地时间返回指定日期的月份(从0到11)。
相关文章:
- 更改默认时区后,如何在本地时间设置时刻格式
- 使用HTML5 Navigation Timing API时,导航开始时间设置为0
- 具有完整时间设置的嵌套 JQuery 动画
- 清除间隔在 6 个时间设置后不起作用间隔
- JQuery 日期选择器 - 根据当前时间设置 MinDate
- 通过Javascript错误将考试时间设置为30分钟
- 如何将东部标准时间设置为日期选择器 (jquery ui) - 使用 javascript
- 如何在javascript中将当前时间设置为其他时间
- 使用JS根据时间设置列的背景颜色
- 如何将一些指定的时间设置为ajax调用,这样如果请求正在花费时间检索数据,它应该来到FAIL块
- 如何将时间设置为定期?JAVA
- 根据一天中的时间设置默认选项的选定值
- 将默认时间设置为mobisroll时间选择器
- 如何在正确的时间设置JS事件
- 客户端时间设置在javascript中破坏了可读日期
- jQuery Timepicker和jQuery Datepair:如何将结束时间设置为15分钟
- Bootstrap DateTimePicker将时间设置为午夜
- 如何将这种日期时间设置为“2013-03-12T22:15:40+08:00”到“12 Mar 2012 02:15:4
- 使用php服务器时间设置Javascript时间
- 如何实现将新的Firebase自定义身份验证最大过期时间设置为1小时的用例