英文:
Having trouble getting current time as a variable in the little script
问题
尝试动态获取此脚本的 "now" 字段的时间。我尝试使用 $.now() 和 Date(),但似乎找不到正确的组合。PS... 我对 JQuery 不熟悉,因为我是新手,所以才来这里。
倒计时有效... 但每次刷新页面时都从列出的时间戳 "now" 开始。此处的变量被提供给我没有编写的主要脚本。
$('.countdown').final_countdown({
start: 1686226400,
end: 1696226400,
now: 1686226400,
seconds: {
borderColor: '#5677fc',
borderWidth: '3'
},
minutes: {
borderColor: '#7e57c2',
borderWidth: '3'
},
hours: {
borderColor: '#4db6ac',
borderWidth: '3'
},
days: {
borderColor: '#d81b60',
borderWidth: '3'
}
}, function() {});
任何帮助都将不胜感激。
尝试设置变量 now = $.now()... 但似乎对我不起作用。
英文:
Trying to get time dynamically for the now field of this script. I have tried using $.now() and Date() but can't seem to find the right combination. PS... I suck at JQuery as I am a newb so this is why I am here
The countdown works... but always starts at the time stamp listed as now every time the page is refreshed. The variable here is fed to primary script which I did not write.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
$('.countdown').final_countdown({
start: 1686226400,
end: 1696226400,
now: 1686226400,
seconds: {
borderColor: '#5677fc',
borderWidth: '3'
},
minutes: {
borderColor: '#7e57c2',
borderWidth: '3'
},
hours: {
borderColor: '#4db6ac',
borderWidth: '3'
},
days: {
borderColor: '#d81b60',
borderWidth: '3'
}
}, function() {});
<!-- end snippet -->
Any help would be appreciated.
Tried setting var now = $.now()... but did not seem to work for me
答案1
得分: -1
将输出从毫秒转换为秒。尝试:
现在:Math.floor($.now() / 1000),
英文:
You need to convert the output from milliseconds to seconds. Try:
now: Math.floor($.now() / 1000),
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论