将时间戳转换为Date类型

来源:互联网 发布:matlab r2013a mac 编辑:程序博客网 时间:2024/05/15 16:16
/** * 将时间戳转换为Date类型 */function add0(m){return m<10?'0'+m:m }function format(date) {var time = new Date(date);var y = time.getFullYear();var m = time.getMonth() + 1;var d = time.getDate();var h = time.getHours();var mm = time.getMinutes();var s = time.getSeconds();return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':'+ add0(mm) + ':' + add0(s);}  

0 0
原创粉丝点击