- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我有这个 javascript 用于自动将日期过滤器设置为上个月的第一天和最后一天:
$(document).ready(function () {
$("#DateFrom").datepicker({ dateFormat: 'dd/mm/yy' });
$("#DateTo").datepicker({ dateFormat: 'dd/mm/yy' });
var now = new Date();
var firstDayPrevMonth = new Date(now.getYear(), now.getMonth() - 1, 1);
var firstDayThisMonth = new Date(now.getYear(), now.getMonth(), 1);
var lastDayPrevMonth = new Date(firstDayThisMonth - 1);
$("#DateFrom").datepicker("setDate", firstDayPrevMonth);
$("#DateTo").datepicker("setDate", lastDayPrevMonth);
});
但是 now.getYear()
返回 111 而不是预期的 2011。有什么明显的我错过了吗?
最佳答案
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/getYear
getYear
is no longer used and has been replaced by thegetFullYear
method.The
getYear
method returns the year minus 1900; thus:
- For years greater than or equal to 2000, the value returned by
getYear
is 100 or greater. For example, if the year is 2026,getYear
returns 126.- For years between and including 1900 and 1999, the value returned by
getYear
is between 0 and 99. For example, if the year is 1976,getYear
returns 76.- For years less than 1900, the value returned by
getYear
is less than 0. For example, if the year is 1800,getYear
returns -100.- To take into account years before and after 2000, you should use
getFullYear
instead ofgetYear
so that the year is specified in full.
关于Javascript date.getYear() 在 2011 年返回 111?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4754938/
本文整理了Java中cesiumlanguagewriter.YearMonthDay.getYear()方法的一些代码示例,展示了YearMonthDay.getYear()的具体用法。这些代码示例
本文整理了Java中java.time.ZonedDateTime.getYear()方法的一些代码示例,展示了ZonedDateTime.getYear()的具体用法。这些代码示例主要来源于Gith
本文整理了Java中java.time.YearMonth.getYear()方法的一些代码示例,展示了YearMonth.getYear()的具体用法。这些代码示例主要来源于Github/Stack
我有一个名为 $F{Fecha} 的时间戳文本字段,我想从中获取日期、月份和年份。我创建了 3 个变量 var1,var2,var3 并且在它们的表达式中我已经把以下 $F{Fecha}.getDay
我有一种方法来计算给定格式(“yyyy-MM-dd”)的制造日期以及产品可以在 int 中使用之前的月份的到期日期。首先,我尝试使用 getYear getMonth getDate of Month
为什么这个 javascript 返回 108 而不是 2008?它得到正确的日期和月份,但不是年份? myDate = new Date(); year = myDate.getYear(); 年
我在 Java 中遇到以下问题(我看到有些人遇到JavaScript中的类似问题,但我使用的是Java) System.out.println(new Date().getYear()); Syste
本文整理了Java中org.joda.time.YearMonth.getYear()方法的一些代码示例,展示了YearMonth.getYear()的具体用法。这些代码示例主要来源于Github/S
本文整理了Java中org.joda.time.Years.getYears()方法的一些代码示例,展示了Years.getYears()的具体用法。这些代码示例主要来源于Github/Stackov
本文整理了Java中org.joda.time.YearMonthDay.getYear()方法的一些代码示例,展示了YearMonthDay.getYear()的具体用法。这些代码示例主要来源于Gi
本文整理了Java中org.jooq.types.YearToMonth.getYears()方法的一些代码示例,展示了YearToMonth.getYears()的具体用法。这些代码示例主要来源于G
这个问题在这里已经有了答案: Why does Javascript getYear() return a three digit number? (14 个答案) getMonth in java
本文整理了Java中org.jfree.data.time.Year.getYear()方法的一些代码示例,展示了Year.getYear()的具体用法。这些代码示例主要来源于Github/Stack
本文整理了Java中net.sf.saxon.value.YearMonthDurationValue.getYears()方法的一些代码示例,展示了YearMonthDurationValue.ge
本文整理了Java中org.exolab.castor.types.Year.getYear()方法的一些代码示例,展示了Year.getYear()的具体用法。这些代码示例主要来源于Github/S
本文整理了Java中de.undercouch.citeproc.zotero.ZoteroItemDataProvider.getYear()方法的一些代码示例,展示了ZoteroItemDataP
我正在使用 JavaScript 的 Date 对象,并且第一次需要提取日期的年份部分。我看到的是一种奇怪的行为。它返回 113 而不是 2013,我无法弄清楚这两个数字如何相关,只是最后两个数字可能
我无法理解为什么 Javascript 中的日期会出现错误。例如... $scope.campaign.date_start = new Date(19/11/2014); Wed Nov 19 20
我目前在用 JavaScript 转换字符串 dateTime 对象时遇到一些问题 我假设这是因为我的字符串无法在 new Date() 中正确使用,但我不确定这是问题所在。 我的输入:“2011-0
我在 webpack 项目中运行 tsc,"core-js": "registry:dt/core-js#0.0.0+20160725163759" 和 "node": “注册表:dt/node#6.
我是一名优秀的程序员,十分优秀!