日期自动变换(按照某种规律自动变更)
2016-06-12 13:55
218 查看
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>测试日期自动变换</title>
<script>
window.onload=function()
{
var mayDate=new Date();//获取日期
var curMonth=mayDate.getMonth();//获取月份(0-11,0代表1月)
var curDate=mayDate.getDate()//获取日期
var mytime=mayDate.toLocaleTimeString()// //获取当前时间
var week=mayDate.getDay()
weekDay=["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
curMonth+=1;
/*取得当前月份有几天*/
var date = new Date();
//获取年份
var year = date.getFullYear();
//获取当前月份
var mouth = date.getMonth() + 1;
//定义当月的天数;
var days ;
//当月份为二月时,根据闰年还是非闰年判断天数
if(mouth == 2){
days= year % 4 == 0 ? 29 : 28;
}
else if(mouth == 1 || mouth == 3 || mouth == 5 || mouth == 7 || mouth == 8 || mouth == 10 || mouth == 12){
//月份为:1,3,5,7,8,10,12 时,为大月.则天数为31;
days= 31;
}
else{
//其他月份,天数为:30.
days= 30;
}
//+-------修改时间规律
if(weekDay[week]==="星期一")
{
curDate+=2
}
else if(weekDay[week]==="星期二")
{
curDate+=1;
}
else if(weekDay[week]==="星期三")
{
curDate+=2;
//curDate = days;
}
else if(weekDay[week]==="星期四")
{
curDate+=1;
}
else if(weekDay[week]==="星期五")
{
curDate+=2;
}
else if(weekDay[week]==="星期六")
{
curDate+=1;
}
else
{
curDate;
};
//------当日期超过30天或者31天减回去
// if(curDate>=32)
// {
// curDate-=1;
//
// }
// else if(curDate>=33)
// {
// curDate-=2;
// };
//
//当月是30天
if(days==30)
{
if(days-curDate<0){//超过当月天数
curDate-=days;
curMonth+=1;//把月份调到下个月份
}else{
curDate;
curMonth;
}
}
else if(days==31)//当月31天
{
if(days-curDate<0){//超过当月天数
curDate-=days;
curMonth+=1;//把月份调到下个月份
}else{
curDate;
curMonth;
}
};
//JQ获取所有对象
$(function()
{
$(".curMonth").html(curMonth);
$(".curDate").html(curDate);
});
}
</script>
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
<style>
.div-relative{position:relative;width:1350px;margin:auto;}
/*----------修改日期样式01--------------*/
.div-Month-1{position: absolute;left: 734px;top:197px;width:143px;height:147px;text-align:center;font-family: "微软雅黑", "宋体";font-size: 88px;color: #49b5a8;} /* 月份位置,字体设置 */
.div-Date-1{ position:absolute;left:954px;top:197px;width:143px; height:147px;text-align:center;font-family: "微软雅黑", "宋体";font-size: 88px;color: #49b5a8;} /* 天数位置,字体设置 */
/*----------修改日期样式02--------------*/
.div-Month-2{position: absolute;left:334px;top:190px;width: 143px;height: 147px;text-align: center;font-family: "微软雅黑", "宋体";font-size: 88px;color: #D11120;} /* 月份位置,字体设置 */
.div-Date-2{ position:absolute; left:510px;top:190px; width:143px; height:147px;text-align: center;font-family: "微软雅黑", "宋体";font-size: 88px;color: #D11120;} /* 天数位置,字体设置 */
</style>
</head>
<body>
<div class="div-relative">
<img src="images/pic617_cq11ccccccc_01.jpg" >
<img src="images/pic617_cq11ccccccc_02.jpg" >
<img src="images/pic617_cq11ccccccc_03.jpg" >
<img src="images/pic617_cq11ccccccc_04.jpg">
<img src="images/pic617_cq11ccccccc_05.jpg">
<div class="div-Month-1 curMonth">月份</div>
<div class="div-Date-1 curDate">天数</div>
</div>
<div style="background:#fffee9;">
<div style="width:1000px; height:460px; position:relative; margin:auto;">
<img src="images/s1219_1bjccc.jpg" />
<div class="div-Month-2 curMonth">月份</div>
<div class="div-Date-2 curDate">天数</div>
</div>
</div>
</body>
</html>
<html>
<head>
<meta charset="utf-8" />
<title>测试日期自动变换</title>
<script>
window.onload=function()
{
var mayDate=new Date();//获取日期
var curMonth=mayDate.getMonth();//获取月份(0-11,0代表1月)
var curDate=mayDate.getDate()//获取日期
var mytime=mayDate.toLocaleTimeString()// //获取当前时间
var week=mayDate.getDay()
weekDay=["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
curMonth+=1;
/*取得当前月份有几天*/
var date = new Date();
//获取年份
var year = date.getFullYear();
//获取当前月份
var mouth = date.getMonth() + 1;
//定义当月的天数;
var days ;
//当月份为二月时,根据闰年还是非闰年判断天数
if(mouth == 2){
days= year % 4 == 0 ? 29 : 28;
}
else if(mouth == 1 || mouth == 3 || mouth == 5 || mouth == 7 || mouth == 8 || mouth == 10 || mouth == 12){
//月份为:1,3,5,7,8,10,12 时,为大月.则天数为31;
days= 31;
}
else{
//其他月份,天数为:30.
days= 30;
}
//+-------修改时间规律
if(weekDay[week]==="星期一")
{
curDate+=2
}
else if(weekDay[week]==="星期二")
{
curDate+=1;
}
else if(weekDay[week]==="星期三")
{
curDate+=2;
//curDate = days;
}
else if(weekDay[week]==="星期四")
{
curDate+=1;
}
else if(weekDay[week]==="星期五")
{
curDate+=2;
}
else if(weekDay[week]==="星期六")
{
curDate+=1;
}
else
{
curDate;
};
//------当日期超过30天或者31天减回去
// if(curDate>=32)
// {
// curDate-=1;
//
// }
// else if(curDate>=33)
// {
// curDate-=2;
// };
//
//当月是30天
if(days==30)
{
if(days-curDate<0){//超过当月天数
curDate-=days;
curMonth+=1;//把月份调到下个月份
}else{
curDate;
curMonth;
}
}
else if(days==31)//当月31天
{
if(days-curDate<0){//超过当月天数
curDate-=days;
curMonth+=1;//把月份调到下个月份
}else{
curDate;
curMonth;
}
};
//JQ获取所有对象
$(function()
{
$(".curMonth").html(curMonth);
$(".curDate").html(curDate);
});
}
</script>
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
<style>
.div-relative{position:relative;width:1350px;margin:auto;}
/*----------修改日期样式01--------------*/
.div-Month-1{position: absolute;left: 734px;top:197px;width:143px;height:147px;text-align:center;font-family: "微软雅黑", "宋体";font-size: 88px;color: #49b5a8;} /* 月份位置,字体设置 */
.div-Date-1{ position:absolute;left:954px;top:197px;width:143px; height:147px;text-align:center;font-family: "微软雅黑", "宋体";font-size: 88px;color: #49b5a8;} /* 天数位置,字体设置 */
/*----------修改日期样式02--------------*/
.div-Month-2{position: absolute;left:334px;top:190px;width: 143px;height: 147px;text-align: center;font-family: "微软雅黑", "宋体";font-size: 88px;color: #D11120;} /* 月份位置,字体设置 */
.div-Date-2{ position:absolute; left:510px;top:190px; width:143px; height:147px;text-align: center;font-family: "微软雅黑", "宋体";font-size: 88px;color: #D11120;} /* 天数位置,字体设置 */
</style>
</head>
<body>
<div class="div-relative">
<img src="images/pic617_cq11ccccccc_01.jpg" >
<img src="images/pic617_cq11ccccccc_02.jpg" >
<img src="images/pic617_cq11ccccccc_03.jpg" >
<img src="images/pic617_cq11ccccccc_04.jpg">
<img src="images/pic617_cq11ccccccc_05.jpg">
<div class="div-Month-1 curMonth">月份</div>
<div class="div-Date-1 curDate">天数</div>
</div>
<div style="background:#fffee9;">
<div style="width:1000px; height:460px; position:relative; margin:auto;">
<img src="images/s1219_1bjccc.jpg" />
<div class="div-Month-2 curMonth">月份</div>
<div class="div-Date-2 curDate">天数</div>
</div>
</div>
</body>
</html>
相关文章推荐
- tcltk实时读写文件【创建log-debug】
- 机器学习常见算法优缺点总结
- js 获取页面元素的值
- VC获取系统时间、程序运行时间(精确到秒,毫秒)的五种方法
- MyBatis 关联查询
- SAP Portal实施分享_自定义LoginModule模块
- Android知识点汇总
- 对AlertDialog.Builder进行封装
- android自定义控件—边缘凹凸的View
- 陆琪众筹出书:一种读者视野的重新诠释_娱乐频道_红网
- (Builder)建造者模式的Java实现
- Guake 0.8.4
- Walker 之侧滑菜单的实现
- 你有什么道理后悔没有早点知道?
- Delphi_检查exe文件是否是"随机基址"
- Oracle 导入dmp文件命令
- [BZOJ4197][Noi2015]寿司晚宴
- Java 集合框架
- 80C51单片机指令助记符英文全称及功能
- dhclient命令