获取后台传的参数

1 获取后台传参数

	//获取后台的参数
	function getQueryString(name) {
		var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
		var r = window.location.search.substr(1).match(reg);
		if(r != null) {
			return unescape(r[2]);
		}
		return null;
	}
  

2 前端时间格式化

	/**
	 * 格式化时间
	 * @param _time Date类型时间
	 * @return yyyy-mm-dd hh:mm
	 * */
	function formatTime(_time) {
		var year = _time.getFullYear();
		var month = _time.getMonth() + 1 < 10 ? "0" + (_time.getMonth() + 1) : _time.getMonth() + 1;
		var day = _time.getDate() < 10 ? "0" + _time.getDate() : _time.getDate();
		var hour = _time.getHours() < 10 ? "0" + _time.getHours() : _time.getHours();
		var minute = _time.getMinutes() < 10 ? "0" + _time.getMinutes() : _time.getMinutes();
		return year + "-" + month + "-" + day + " " + hour + ":" + minute;
	}

 

 

 

 

 

 


版权声明:本文为qq_42917455原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。