倒计时jquery 当前数据
countdown jquery current data
我有倒计时java脚本代码
<script type="text/javascript">
$('document').ready(function() {
'use strict';
$('.countdown').final_countdown({
'start': 1452402000,
'end': 1458298800,
'now': 1452402000
});
});
</script>
我想将 'now' 设置为 $.now()
或获取当前日期,但是当我将其设置为
'now': $.now()
有任何帮助
$.now()
returns 时间而非日期对象。相反,您应该使用 Date()
对象来获取日期或使用 Date 对象将其转换为日期。
来自文档:
jQuery.now()
Description: Return a number representing the current time.
The $.now() method is a shorthand for the number returned by the expression (new Date).getTime().
var t = $.now();
var d = new Date(t);
$('pre')
.append('$.now()::::::'+t+'<br>')
.append('new Date(t)::::::'+d);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<pre></pre>
看起来 final_countdown
预计时间为 Unix time(自 1.1.1970 以来的秒数)但是
$.now()
returns 自 1.1.1970 以来的毫秒数
$('document').ready(function() {
'use strict';
$('.countdown').final_countdown({
'start': 1452402000,
'end': 1458298800,
'now': Math.floor($.now() / 1000) // strip the milliseconds
});
});
我有倒计时java脚本代码
<script type="text/javascript">
$('document').ready(function() {
'use strict';
$('.countdown').final_countdown({
'start': 1452402000,
'end': 1458298800,
'now': 1452402000
});
});
</script>
我想将 'now' 设置为 $.now()
或获取当前日期,但是当我将其设置为
'now': $.now()
有任何帮助
$.now()
returns 时间而非日期对象。相反,您应该使用 Date()
对象来获取日期或使用 Date 对象将其转换为日期。
来自文档:
jQuery.now()
Description: Return a number representing the current time.
The $.now() method is a shorthand for the number returned by the expression (new Date).getTime().
var t = $.now();
var d = new Date(t);
$('pre')
.append('$.now()::::::'+t+'<br>')
.append('new Date(t)::::::'+d);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<pre></pre>
看起来 final_countdown
预计时间为 Unix time(自 1.1.1970 以来的秒数)但是
$.now()
returns 自 1.1.1970 以来的毫秒数
$('document').ready(function() {
'use strict';
$('.countdown').final_countdown({
'start': 1452402000,
'end': 1458298800,
'now': Math.floor($.now() / 1000) // strip the milliseconds
});
});