<script type="text/javascript">
function today(){
var today=new Date();
var h=today.getFullYear();
var m=today.getMonth()+1;
var d=today.getDate();
return h+"-"+m+"-"+d;
}
function getMonday()
{
var today=new Date();
var weekday=today.getDay();
var dd=new Date(1000*60*60*24*(1-weekday) + today.getTime());
var y = dd.getFullYear();
var m = dd.getMonth()+1;//获取当前月份的日期
m=parseInt(m,10);
if(m<10){
m="0"+m;
}
var d = dd.getDate();
d=parseInt(d,10);
if(d<10){
d="0"+d;
}
return y+"-"+m+"-"+d;
}
function getSunday()
{
var today=new Date();
var weekday=today.getDay();
var dd=new Date(1000*60*60*24*(7-weekday) + today.getTime());
var y = dd.getFullYear();
var m = dd.getMonth()+1;//获取当前月份的日期
m=parseInt(m,10);
if(m<10){
m="0"+m;
}
var d = dd.getDate();
d=parseInt(d,10);
if(d<10){
d="0"+d;
}
return y+"-"+m+"-"+d;
}
document.getElementById("input_monday").value=getMonday();
document.getElementById("input_sunday").value=getSunday();
</script>
input 默认日期为当前时间 或本周一 周末
最新推荐文章于 2022-05-17 14:14:14 发布