Extjs的datefield怎么获取当前系统时间所属月月初到月末
2个回答
展开全部
var myDate = new Date();
var year = myDate.getFullYear();
var month = myDate.getMonth()+1;
if (month<10){
month = "0"+month;
}
var firstDay = year+"-"+month+"-01";
var myDate = new Date(year,month,0);
var lastDay = year+"-"+month+"-"+myDate.getDate();
//然后复制即可
datefeildStart.setValue(firstDay);
datefeildEnd.setValue(lastDay);
推荐于2016-10-13
展开全部
日期控件:
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 myDate = new Date();
var year = myDate.getFullYear();
var month = myDate.getMonth()+1;
if (month<10){
month = "0"+month;
}
var firstDay = year+"-"+month+"-01";
var myDate = new Date(year,month,0);
var lastDay = year+"-"+month+"-"+myDate.getDate();
//
datefeildStart.setValue(firstDay);
datefeildEnd.setValue(lastDay);
//获取当前日期的前一天
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";//本月第一天
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 myDate = new Date();
var year = myDate.getFullYear();
var month = myDate.getMonth()+1;
if (month<10){
month = "0"+month;
}
var firstDay = year+"-"+month+"-01";
var myDate = new Date(year,month,0);
var lastDay = year+"-"+month+"-"+myDate.getDate();
//
datefeildStart.setValue(firstDay);
datefeildEnd.setValue(lastDay);
//获取当前日期的前一天
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";//本月第一天
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询