easyUI 设置日期控件当前日期前一天 当前日期前一个月(只显示年月)
2017-01-20 11:28
567 查看
<span style="padding-left:5px;">时间 :  </span>
<input type="text" name="time" id="time" class="easyui-datebox" style="width:150px;height:26px;" />
//获取当前日期前一天
function getCurrentMonthFirst(){
var date=new Date();
date.setDate(date.getDate()-1);
return date;
}
//获取当月第一天
function getCurrent(){
var date=new Date();
date.setDate(1);
return date;
}
//以下代码初始化执行
$(document).ready(function(){
//设置初始时间
$("#time").datebox('setValue', formatDate(getCurrentMonthFirst()));
var startTime=formatDate(getCurrentMonthFirst());
}
//当前日期前一个月(只显示年月)
$(function(){
var currTime=new Date();
var strDate;
if((currTime.getMonth()+1)=="1"){
strDate=(currTime.getFullYear()-1)+"-"+(currTime.getMonth());
}else{
strDate=currTime.getFullYear()+"-"+(currTime.getMonth());
}
//var strDate=currTime.getFullYear()+"-"+(currTime.getMonth());
$('#time').datebox({formatter:function(date){
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? '0' + m : m;
return y.toString() + '-' + m.toString();
},parser:function(date){
console.log(date);
if (date) {
return new Date(String(date).substring(0, 4) + '-'
+ String(date).substring(5,7));
} else {
return new Date();
}
}});
$('#time').datebox('setValue',strDate);//默认加载当前月份
});
<input type="text" name="time" id="time" class="easyui-datebox" style="width:150px;height:26px;" />
//获取当前日期前一天
function getCurrentMonthFirst(){
var date=new Date();
date.setDate(date.getDate()-1);
return date;
}
//获取当月第一天
function getCurrent(){
var date=new Date();
date.setDate(1);
return date;
}
//以下代码初始化执行
$(document).ready(function(){
//设置初始时间
$("#time").datebox('setValue', formatDate(getCurrentMonthFirst()));
var startTime=formatDate(getCurrentMonthFirst());
}
//当前日期前一个月(只显示年月)
$(function(){
var currTime=new Date();
var strDate;
if((currTime.getMonth()+1)=="1"){
strDate=(currTime.getFullYear()-1)+"-"+(currTime.getMonth());
}else{
strDate=currTime.getFullYear()+"-"+(currTime.getMonth());
}
//var strDate=currTime.getFullYear()+"-"+(currTime.getMonth());
$('#time').datebox({formatter:function(date){
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? '0' + m : m;
return y.toString() + '-' + m.toString();
},parser:function(date){
console.log(date);
if (date) {
return new Date(String(date).substring(0, 4) + '-'
+ String(date).substring(5,7));
} else {
return new Date();
}
}});
$('#time').datebox('setValue',strDate);//默认加载当前月份
});
相关文章推荐
- easyUI 设置日期控件当前日期前一天 当前日期前一个月(只显示年月)
- easyUI 设置日期控件当前日期前一天 当前日期前一个月(只显示年月)
- EasyUi日期控件datebox设置,只显示年月
- EasyUi日期控件datebox设置,只显示年月,也只能选择年月
- easyui-datebox 日期控件 只显示年月 不显示日
- Flex中如何设置或取消DateChooser控件当前日期高亮显示(highlighting)的例子
- easyui-datebox 日期控件 只显示年月 不显示日
- 修改easyui日期控件只显示年月,并且只能选择年月
- easyui-datebox 日期控件 只显示年月 不显示日
- Devexpress 的日期控件显示只设置年月
- 修改easyui日期控件只显示年月,并且只能选择年月
- jquery easyui datebox 时间控件默认显示当前日期的实现方法
- ExtJs4.0日期控件只显示年月按年月格式会跳月的解决办法
- DatePicker控件/日期控件,只显示年月/隐藏日
- 五种情况下会刷新控件状态(刷新所有子FWinControls的显示)——从DFM读取数据时、新增加子控件时、重新创建当前控件的句柄时、设置父控件时、显示状态被改变时
- easyUI的列表控件(datagrid)日期列不能正确显示Json格式数据的解决方法
- Java获取当前日期的前一个月,前一天的时间
- 安卓开发中的双日期选择控件(可隐藏日,只显示年月)
- 安卓开发中的双日期选择控件(可隐藏日,只显示年月)
- 安卓开发中的双日期选择控件(可隐藏日,只显示年月)