js将时间格式Wed May 25 13:55:10 CST 2016转换为2016-5-25格式再得到7天后的时间

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_30641447/article/details/71535427


<script>
		$(function(){
			var a=$("#endTime").val();
			var c=todate(a, "-", true);
			var d=fun_submit(c);
			var newEndTime = $('#newEndTime');
			newEndTime.append(d+"前");
		})
		//将时间转换
		function todate(inputstr, showsplit, showweek) {
			debugger;
			//Wed Mar 22 13:38:37 CST 2017
			inputstr = inputstr + ""; //末尾加一个空格
			var date = "";
			var month = new Array();
			var week = new Array();
			month["Jan"] = 1; month["Feb"] = 2; month["Mar"] = 3; month["Apr"] = 4; month["May"] = 5; month["Jan"] = 6;
			month["Jul"] = 7; month["Aug"] = 8; month["Sep"] = 9; month["Oct"] = 10; month["Nov"] = 11; month["Dec"] = 12;
			week["Mon"] = "一"; week["Tue"] = "二"; week["Wed"] = "三"; week["Thu"] = "四"; week["Fri"] = "五"; week["Sat"] = "六"; week["Sun"] = "日";
			str = inputstr.split(" ");
			date = str[5];
			var dateArray=new Array();
			dateArray[0]=7;

			debugger;
			date +=+showsplit +month[str[1]]+showsplit+ str[2]+dateArray[0];
			/*if(showweek){
				date += "    " +"("+ " 星期" + week[str[0]]+")";
			}*/
			return date;
		}
		//获取后7天的日期
		function fun_submit(arg){
				var date1 = new Date(arg);
				var date2 = new Date(date1);
				date2.setDate(date1.getDate()+7);
				var times = date2.getFullYear()+"年 "+(date2.getMonth()+1)+"月 "+date2.getDate()+"号";
				return times;
		}

	</script>


展开阅读全文

没有更多推荐了,返回首页