• JS获取当前时间到30天之后的日期区间


    <!doctype html>
    <html>
    
    	<head>
    		<meta charset="utf-8">
    		<title>获取当前时间到30天之后的日期区间</title>
    	</head>
    
    	<body>
    		<script>
    			var startDate = new Date();
    			var endDate = new Date();
    			endDate.setDate(startDate.getDate() + 30);
    			var dataArr = [];
    			var weeks = ['日', '一', '二', '三', '四', '五', '六'];
    			while((endDate.getTime() - startDate.getTime()) >= 0) {
    				var month = (startDate.getMonth() + 1).toString().length == 1 ? "0" + (startDate.getMonth() + 1).toString() : (startDate.getMonth() + 1);
    				var day = startDate.getDate().toString().length == 1 ? "0" + startDate.getDate() : startDate.getDate();
    				var week = weeks[startDate.getDay()];
    				dataArr.push(month + "月" + day + '日(周' + week + ')');
    				startDate.setDate(startDate.getDate() + 1);
    
    			}
    			dataArr[0] = '今天' + dataArr[0].slice(6, 10);
    			dataArr[1] = '明天' + dataArr[1].slice(6, 10);
    			dataArr[2] = '后天' + dataArr[2].slice(6, 10);
    			console.log(dataArr);
    		</script>
    	</body>
    
    </html>
    

      

  • 相关阅读:
    currentColor
    clip:rect()
    webkitAnimationEnd事件与webkitTransitionEnd事件
    正方体旋转demo
    由-webkit-transform-style:preserve-3d;所想
    设置网站的图标
    条件注释判断浏览器
    怎样动态地插入不会暴露给用户的JS文件
    IOC Unity
    C# 线程
  • 原文地址:https://www.cnblogs.com/yiweiyihang/p/7687799.html
Copyright © 2020-2023  润新知