function getLocalTime(nS, f) {
let format = 'YYYY-MM-DD hh:mm:ss' // 日期格式,yyyy: 年,m:月,d:天,hh:时,mm:分,ss:秒
if (f) {
format = f
}
let time
if (nS) {
time = new Date(nS * 1000)
} else {
time = new Date()
}
let y = time.getFullYear()
let m = time.getMonth() + 1
let d = time.getDate()
let h = time.getHours()
let mm = time.getMinutes()
let s = time.getSeconds()
m = m < 10 ? '0' + m : m
d = d < 10 ? '0' + d : d
h = h < 10 ? '0' + h : h
mm = mm < 10 ? '0' + mm : mm
s = s < 10 ? '0' + s : s
let fullTime = format.replace('YYYY', y).replace('MM', m).replace('DD', d).replace('hh', h).replace('mm', mm).replace('ss', s)
return fullTime
}
getLocalTime(1534301216,'YYYY/MM/DD hh:mm:ss') //"2018/08/15 10:46:56"
function GetUrlParam(url, name) {
var pattern = new RegExp("[?&]" + name + "\=([^&]+)", "g");
var matcher = pattern.exec(url);
var items = null;
if (null != matcher) {
try {
items = decodeURIComponent(decodeURIComponent(matcher[1]));
} catch (e) {
try {
items = decodeURIComponent(matcher[1]);
} catch (e) {
items = matcher[1];
}
}
}
return items;
}
(2)更改参数值
function replaceParamVal(paramName,replaceWith) {
var oUrl = this.location.href.toString();
var re=eval('/('+ paramName+'=)([^&]*)/gi');
var nUrl = oUrl.replace(re,paramName+'='+replaceWith);
this.location = nUrl;
window.location.href=nUrl
}
四、网页中效果
1.tab切换
function tabsChange(el,e2) { //e1是点击的一组元素,e2是切换显示的元素
el.click(function () {
var _index = $(this).index()
$(this).siblings().removeClass('on')
$(this).addClass('on')
e2.eq(_index).siblings().removeClass('on')
e2.eq(_index).addClass('on')
})
}