// 获取网址的get参数 var GET = function(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return (r[2]); return null; }
// 13位时间戳转日期 var getLocalTime = function(nS) { //return new Date(parseInt(nS)).toLocaleString().replace(/:\d{1,2}$/,‘ ‘); var date = new Date(nS); var Y = date.getFullYear() + ‘/‘; var M = (date.getMonth() + 1 < 10 ? ‘0‘ + (date.getMonth() + 1) : date.getMonth() + 1) + ‘/‘; var D = (date.getDate() < 10 ? ‘0‘ + (date.getDate()) : date.getDate()) + ‘ ‘; var h = date.getHours() + ‘:‘; var m = (date.getMinutes() < 10 ? ‘0‘ + (date.getMinutes()) : date.getMinutes()) + ‘ ‘; //var s = date.getSeconds(); return Y + M + D + h + m; }
// 数组对象排序 data.sort(keysrt("firstWord")); var keysrt = function(propertyName) { return function(object1, object2) { var value1 = object1[propertyName]; var value2 = object2[propertyName]; if (value2 < value1) { return 1; } else if (value2 > value1) { return -1; } else { return 0; } } }
原文:http://www.cnblogs.com/woodk/p/5787154.html