数码资讯
用Javascript实时显示北京时间的方法
本文介绍了用javascript实时显示北京时间的方法,供大家参考: 该页实时显示北京时间。更改时区也可以用作显示世界时间。代码如下: 复制代码代码如下所示: date.prototype.strftime =函数(格式){ var { { { { M +:this.getmonth()+ 1, /
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
本文介绍了用javascript实时显示北京时间的方法,供大家参考:
该页实时显示北京时间。更改时区也可以用作显示世界时间。代码如下:
复制代码代码如下所示:
date.prototype.strftime =函数(格式){
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() / /毫秒
}
如果((y +)测试(格式)){
格式= format.replace(regexp。1美元,((this.getfullyear()+)。Substr(4—9。1美元。长度));
}
对于(var在o中){
如果(新规则((钾))。试验(格式)){
格式= format.replace(regexp。1美元,regexp。1美元。长度= = 1 O { }:K(00 + O { k })。Substr((+ O { k })。长度));
}
}
返回格式;
}
功能utctolocaltimestring(D,格式){
无功timeoffsetinhours =(新的日期()GetTimezoneOffset() / 60)+ 10;
d.sethours(d.gethours()+ timeoffsetinhours);
返回d.strftime(格式);
}
setInterval(){ var函数(时间= utctolocaltimestring(新的日期(),'yyyy /毫米/ DD HH:MM:SS);document.getelementbyid(bjtime ).innerHTML = =;},1000);
希望本文能对大家的javascript程序设计有所帮助。
该页实时显示北京时间。更改时区也可以用作显示世界时间。代码如下:
复制代码代码如下所示:
date.prototype.strftime =函数(格式){
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() / /毫秒
}
如果((y +)测试(格式)){
格式= format.replace(regexp。1美元,((this.getfullyear()+)。Substr(4—9。1美元。长度));
}
对于(var在o中){
如果(新规则((钾))。试验(格式)){
格式= format.replace(regexp。1美元,regexp。1美元。长度= = 1 O { }:K(00 + O { k })。Substr((+ O { k })。长度));
}
}
返回格式;
}
功能utctolocaltimestring(D,格式){
无功timeoffsetinhours =(新的日期()GetTimezoneOffset() / 60)+ 10;
d.sethours(d.gethours()+ timeoffsetinhours);
返回d.strftime(格式);
}
setInterval(){ var函数(时间= utctolocaltimestring(新的日期(),'yyyy /毫米/ DD HH:MM:SS);document.getelementbyid(bjtime ).innerHTML = =;},1000);
希望本文能对大家的javascript程序设计有所帮助。
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。