var timeStamp = function(stringTime) { var timestamp = stringTime ? Date.parse(newDate(stringTime)) : 0; return timestamp / 1000; //2014-07-10 10:21:12的时间戳为:1404958872 }
8.获取url参数
1 2 3 4 5 6 7 8 9 10 11
var getUrlParam = function() { var strUrl = window.location.search.slice(1); var arrUrl = strUrl.split("&"); var param = {} if (arrUrl.length) { for (var index in arrUrl) { param[arrUrl[index].split("=")[0]] = arrUrl[index].split("=")[1] } } return param; }
1 2 3 4 5 6 7 8 9 10 11 12 13
functionparseUrl(name,url){ url = url || location.href let arr = url.split(/\?|#/) let search = arr[1] let parames = search ? search.split('&') : [] let result = {} parames.map(parame=>{ let item = parame.split('=') result[item[0]] = item[1] }) return name ? result[name] : result; }