数码资讯
js如何将UTC格式时间转换为本地格式
复制代码代码如下所示: date.prototype.format =函数(格式){ var { { { { M +:this.getmonth()+ 1, / /月 D:this.getdate(), / /天 H:this.gethours(), / /小时 M +:this.getminute
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
复制代码代码如下所示:
date.prototype.format =函数(格式){
var { { { {
M +:this.getmonth()+ 1, / /月
D:this.getdate(), / /天
H:this.gethours(), / /小时
M +:this.getminutes(), / /分钟
+:this.getseconds(), / /二
Q+:Math.floor(((this.getmonth()+ 3)/ 3), / /季度
S: this.getMilliseconds () //millisecond
}
如果( / /(Y +)。试验(格式))格式(1美元= format.replace正则表达式,
(this.getfullyear()+)。Substr(4—9。1美元。长度));
为(O变量K)如果(new RegExp((钾))。试验(格式))
格式(1美元= format.replace正则表达式,
正则表达式。1.length = 1美元} { k:
(00+ O { k })。Substr((+ O { k })。长度));
返回格式;
}
无功tempdate =新的日期();
TempDate.toLocaleDateString()9月4日 / / 2013
TempDate.format(yyyy-mm-dd) / / 2013-09-04
date.prototype.format =函数(格式){
var { { { {
M +:this.getmonth()+ 1, / /月
D:this.getdate(), / /天
H:this.gethours(), / /小时
M +:this.getminutes(), / /分钟
+:this.getseconds(), / /二
Q+:Math.floor(((this.getmonth()+ 3)/ 3), / /季度
S: this.getMilliseconds () //millisecond
}
如果( / /(Y +)。试验(格式))格式(1美元= format.replace正则表达式,
(this.getfullyear()+)。Substr(4—9。1美元。长度));
为(O变量K)如果(new RegExp((钾))。试验(格式))
格式(1美元= format.replace正则表达式,
正则表达式。1.length = 1美元} { k:
(00+ O { k })。Substr((+ O { k })。长度));
返回格式;
}
无功tempdate =新的日期();
TempDate.toLocaleDateString()9月4日 / / 2013
TempDate.format(yyyy-mm-dd) / / 2013-09-04
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。