嗨,请帮助我如何添加时区取决于我的电脑或手机的当前时间。此代码适用于我的目标网页。感谢
这是我的代码..
//创建倒计时
var Countdown = {
//类似骨干的结构 $ el:$('。countdown'),
// Params countdown_interval:null, total_seconds:0,
//初始化倒计时
init:function(){
// DOM
this.$ = {
days : this.$el.find('.bloc-time.days .figure'),
hours : this.$el.find('.bloc-time.hours .figure'),
minutes: this.$el.find('.bloc-time.min .figure'),
seconds: this.$el.find('.bloc-time.sec .figure')
};
// Init countdown values
this.values = {
days : this.$.days.parent().attr('data-init-value'),
hours : this.$.hours.parent().attr('data-init-value'),
minutes: this.$.minutes.parent().attr('data-init-value'),
seconds: this.$.seconds.parent().attr('data-init-value'),
};
// Initialize total seconds
this.total_seconds = this.values.days * 60 * 60 * 60 + (this.values.hours * 60 * 60) + (this.values.minutes * 60) + this.values.seconds;
// Animate countdown to the end
this.count();
},
count:function(){
var that = this,
$day_1 = this.$.days.eq(0),
$day_2 = this.$.days.eq(1),
$hour_1 = this.$.hours.eq(0),
$hour_2 = this.$.hours.eq(1),
$min_1 = this.$.minutes.eq(0),
$min_2 = this.$.minutes.eq(1),
$sec_1 = this.$.seconds.eq(0),
$sec_2 = this.$.seconds.eq(1);
this.countdown_interval = setInterval(function() {
if(that.total_seconds > 0) {
--that.values.seconds;
if(that.values.minutes >= 0 && that.values.seconds < 0) {
that.values.seconds = 59;
--that.values.minutes;
}
if(that.values.hours >= 0 && that.values.minutes < 0) {
that.values.minutes = 59;
--that.values.hours;
}
if(that.values.days >= 0 && that.values.hours < 0) {
that.values.hours = 24;
--that.values.days;
}
// Update DOM values
// Days
that.checkHour(that.values.days, $day_1, $day_2);
// Hours
that.checkHour(that.values.hours, $hour_1, $hour_2);
// Minutes
that.checkHour(that.values.minutes, $min_1, $min_2);
// Seconds
that.checkHour(that.values.seconds, $sec_1, $sec_2);
--that.total_seconds;
}
else {
clearInterval(that.countdown_interval);
document.getElementsByClassName('countdown')[0].style.visibility = 'hidden';
document.getElementsByClassName("countdown-ex")[0].innerHTML = "EXPIRED!";
}
}, 1000);
},
animateFigure:function($ el,value){
var that = this,
$top = $el.find('.top'),
$bottom = $el.find('.bottom'),
$back_top = $el.find('.top-back'),
$back_bottom = $el.find('.bottom-back');
// Before we begin, change the back value
$back_top.find('span').html(value);
// Also change the back bottom value
$back_bottom.find('span').html(value);
// Then animate
TweenMax.to($top, 0.8, {
rotationX : '-180deg',
transformPerspective: 300,
ease : Quart.easeOut,
onComplete : function() {
$top.html(value);
$bottom.html(value);
TweenMax.set($top, { rotationX: 0 });
}
});
TweenMax.to($back_top, 0.8, {
rotationX : 0,
transformPerspective: 300,
ease : Quart.easeOut,
clearProps : 'all'
});
},
checkHour:function(value,$ el_1,$ el_2){
var val_1 = value.toString().charAt(0),
val_2 = value.toString().charAt(1),
fig_1_value = $el_1.find('.top').html(),
fig_2_value = $el_2.find('.top').html();
if(value >= 10) {
// Animate only if the figure has changed
if(fig_1_value !== val_1) this.animateFigure($el_1, val_1);
if(fig_2_value !== val_2) this.animateFigure($el_2, val_2);
}
else {
// If we are under 10, replace first figure with 0
if(fig_1_value !== '0') this.animateFigure($el_1, 0);
if(fig_2_value !== val_1) this.animateFigure($el_2, val_1);
}
} };
//我们走了!
Countdown.init();
答案 0 :(得分:0)
将moment.js与moment-timezone add(link)结合使用,支持时区猜测
import pymysql
#from Roster import x
x='bh16'
IT = pymysql.connect(host='xx.xxx.xx.xx', user='xxxx', password='xxxx',
db='xxxx')#Connect to the IT database
Others = pymysql.connect(host='xx.xx.xx.x0', user='xxxxxxx', password='xxxx', db='samsdb')#Connect to the non IT database
a=IT.cursor() # Open Cursor for IT database
b=Others.cursor()#Open Cursor for non-IT database
m= ("select verticalorg from tbl_employeedetails where empntid=%s" %x)
a.execute(m)
b.execute(m)
c=a.fetchall()
d=b.fetchall()
print(c)
如果您可以保证您的用户正在运行支持全新ECMAScript国际化API的浏览器,您可以像这样获得用户的时区:
moment.tz.guess().