Ext的DateField获取当前日期的前一天、当前日期、本月的第一天

日期控件:

new Ext.form.DateField( {
         fieldLabel : '开始日期',
         id : 'beginDate',
         width : 90,
         //value:sys.sysDate.substring(0,7)+'-01',
         value: timeYesterday,
         format:'Y-m-d',
         allowBlank : true,
         listeners : {
          specialkey : function(field, e){
           if(e.getKey() == Ext.EventObject.ENTER){
            loadGrid(settlementRrunStatusQueryDetailDatastore);
           }
          }
         }
        })

 

 

timeYesterday:

 

var curDate = new Date();
var preDate = new Date(curDate.getTime() - 24*60*60*1000);  

 

//获取当前日期的前一天
var timeYesterday = preDate.format("Y") +"-" +preDate.format("m") + "-"+(preDate.format("d"));//昨天

 

//获取当前日期

var timeToday = curDate.format("Y") +"-" +curDate.format("m") + "-"+(curDate.format("d"));//今天

 

//获取本月的第一天

var timeFirstDay = preDate.format("Y") +"-" +preDate.format("m") + "-01";//本月第一天

你可能感兴趣的:(Field)