最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JS如何將UTC格式時(shí)間轉(zhuǎn)本地格式

 更新時(shí)間:2013年09月04日 17:37:19   作者:  
UTC格式時(shí)間想必大家并不陌生,那么怎么可以將其轉(zhuǎn)換為本地格式呢?其實(shí)很簡(jiǎn)單,下面的方法會(huì)幫助大家實(shí)現(xiàn)這一想法
復(fù)制代碼 代碼如下:

Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
}

var TempDate = new Date();

TempDate.toLocaleDateString()//2013年9月4日

TempDate.format("yyyy-MM-dd")//2013-09-04

相關(guān)文章

最新評(píng)論

汶川县| 栾川县| 汝城县| 大埔区| 安丘市| 上饶市| 清镇市| 城口县| 文成县| 哈尔滨市| 那曲县| 子长县| 大渡口区| 罗江县| 东辽县| 措美县| 安丘市| 民乐县| 梁河县| 孝昌县| 太保市| 廉江市| 舟山市| 于田县| 沅江市| 陵水| 苍梧县| 宁陕县| 卢龙县| 方城县| 广汉市| 金昌市| 屏东县| 安国市| 长春市| 舒城县| 柳江县| 阜康市| 灵丘县| 肇东市| 伊金霍洛旗|