减去视图中新日期()中的天数

Subtracting days in new Date() in a view

本文关键字:日期 新日期 视图      更新时间:2023-09-26

我得到了这段代码:

    xtype: 'datefield',
    editable: false,
    itemId: 'start-date-field',
    fieldLabel: 'Från',
    labelWidth: 50,
    format: 'Y-m-d',
    value: new Date(),
    disabled: true

我正试图从"new Date()"中减去一些日子,但我的谷歌主页不够好,这对大多数人来说可能已经足够容易了。我尝试了新的Date().getDay-30,但这只会产生一个错误。

xtype: 'datefield',
editable: false,
itemId: 'start-date-field',
fieldLabel: 'Från',
labelWidth: 50,
format: 'Y-m-d',
value: (function() {var lastMonth = new Date(); return lastMonth.setDate(lastMonth.getDate()-30), lastMonth;})(),
disabled: true

JSFiddle