我给同年时倒计时插件不起作用

时间:2017-06-01 09:41:46

标签: javascript jquery

我正在为电子商务网站使用多事件倒计时器。当我使用下一年作为年度值时,它正常工作(例如,它正在使用日期" 02/05/2018 05:55:55"但是当我使用时没有工作使用" 02/07/2017 05:55:55")



$('[data-countdown]').each(function() {
   var $this = $(this), finalDate = $(this).data('countdown');
   $this.countdown(finalDate, function(event) {
     $this.html(event.strftime('%D days %H:%M:%S'));
   });
 });

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/hilios/jQuery.countdown/2.0.4/dist/jquery.countdown.min.js"></script>
<div id="example1" data-countdown="01/01/2018 05:06:59"></div>
<div id="example2" data-countdown="01/07/2017"></div>
<div id="example3" data-countdown="01/01/2018"></div>
<div id="example4" data-countdown="05/07/2017"></div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

您需要与白天交换月份,因为格式为“月/日/年”:

<div id="example1" data-countdown="01/01/2018 05:06:59"></div>
<div id="example2" data-countdown="07/01/2017"></div>
<div id="example3" data-countdown="01/01/2018"></div>
<div id="example4" data-countdown="07/05/2017"></div>  

http://jsfiddle.net/3h9tyrvh/157/