日期自动变换(按照某种规律自动变更)
来源:互联网 发布:最流行的编程语言 编辑:程序博客网 时间:2024/04/28 19:04
<!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>
0 0
- 日期自动变换(按照某种规律自动变更)
- ubuntu 按照日期自动备份
- oracle按照日期自动进行表分区
- sql server 按照日期自动生成单据编号的函数
- textarea自动变换高度
- 图片自动变换
- 变更域内自动发现地址记录!
- IDoc-变更自动运行-change pointer 。
- Chrome对自动播放作出变更
- 日期的自动获取(自动获取填单日期)
- 按照某种方式打印矩阵
- 自动日期输入
- 日期自动扩展
- js 日期自动加月数
- js 自动添加日期
- 日期自动补零
- CxGrid按照查询结果自动创建字段
- 每日一练(七)自动变换节点
- js 获取页面元素的值
- jQuery Ajax 实例 ($.ajax、$.post、$.get)
- 大数加法、减法和乘法
- 机器学习常见算法优缺点总结
- js中如果long类型值过长,字段自动截取问题
- 日期自动变换(按照某种规律自动变更)
- svn如何与服务器断开连接
- 我所理解的设计模式
- DIY一个VR小钢炮
- Popupwindow显示
- django传递数据给JS
- 如何让Ubuntu系统支持WebP图片格式
- POI操作WORD文档,生成的新文档为空白文档 -- 待解决
- Python 元组详解