本站即日起正式部署SSL证书启用https安全连接, 联系站长:416326801#qq.com(#改成@)

Latest from the blog

js获取cookie值

标签: JavaScript

/**
 * js获取cookie值
 * @param Name
 * @returns
 */
function get_cookie(Name) {
	var search = Name + "=" // 查询检索的值
	var returnvalue = ""; // 返回值
	if (document.cookie.length > 0) {
		sd = document.cookie.indexOf(search);
		if (sd != -1) {
			sd += search.length;
			end = document.cookie.indexOf(";", sd);
			if (end == -1)
				end = document.cookie.length;
			// unescape() 函数可对通过 escape() 编码的字符串进行解码。
			returnvalue = unescape(document.cookie.substring(sd, end))
		}
	}
	return returnvalue;
}

js时间戳转换

标签: JavaScript

//时间戳转换
function timestampToSecond(timestamp) {
	var date = new Date(timestamp);
	h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + '小时';
	m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()+"分";
	s = date.getSeconds();

	return h + m;
}
function timestampToTime(timestamp) {
	var date = new Date(timestamp);
	Y = date.getFullYear() + '-';
	M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
	D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
	h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
	m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
	s = date.getSeconds();

	return Y + M + D + h + m;
}
function timestampToTimeToMonth(timestamp) {
	var date = new Date(timestamp);
	Y = date.getFullYear() + '-';
	M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);

	return Y + M;
}

function timestampToTimeToDay(timestamp) {
	var date = new Date(timestamp);
	Y = date.getFullYear() + '-';
	M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
	D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());

	return Y + M + D;
}
1 2 3 4 5 6 ... Next »... Last »