【问题标题】:jquery countdown show datejquery倒计时显示日期
【发布时间】:2015-04-21 14:54:18
【问题描述】:

像这样使用这个 jquery 倒计时脚本http://keith-wood.name/countdown.html

 <script type="text/javascript">
$(function () {
    var today = new Date();
    var tomorrow = new Date();
    tomorrow.setDate(today.getDate() + 1);
    var tm = new Date(tomorrow.getFullYear(),tomorrow.getMonth(), tomorrow.getDate());
    $('#defaultCountdown').countdown({until: tm});
});
</script>

还有这个

<div id="defaultCountdown"></div>

允许我根据电脑时间显示 24 小时的倒计时。现在我也想得到这个日期,但我不想要当前日期我想要第二天的日期

【问题讨论】:

  • 所以要倒计时 48 小时?
  • 不,我想显示 4 月 21 日星期二这样的日期,但我需要始终是第二天。如果今天是星期二,我需要显示星期三等等。

标签: jquery countdown


【解决方案1】:

我不确定你的插件是否允许这种功能,所以你必须自己制作这样的功能:

<style>
#tomorrow{
    width: 240px; 
    height: 45px;
    margin-bottom:10px;
}
#tomorrow .countdown-section{
    padding-left:5px;
}
</style>
<div id="tomorrow" class="is-countdown">
    <span class='countdown-section'><span class='countdown-amount' id='tomorrowDay'></span><span class='countdown-period'>Day</span></span>
    <span class='countdown-section'><span class='countdown-amount' id='tomorrowDate'></span><span class='countdown-period'>Date</span></span>
    <span class='countdown-section'><span class='countdown-amount' id='tomorrowMonth'></span><span class='countdown-period'>Month</span></span>
</div>
<script>
function setTomorrow(){
    var today = new Date();
    var tomorrow = new Date();
    tomorrow.setDate(tomorrow.getDate() + 1);   
    tomorrow.setHours(0);   
    tomorrow.setMinutes(0); 
    tomorrow.setSeconds(0); 
    tomorrow.setMilliseconds(0);    
    var timer = (tomorrow - today);
    $("#tomorrowDay").text(['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][tomorrow.getDay()]);
    $("#tomorrowDate").text(tomorrow.getDate());
    $("#tomorrowMonth").text(['January','February','','March','April','May','June','July','August','September','October','November','December'][tomorrow.getMonth()]);  
    setTimeout(function(){ setTomorrow(); }, timer);    
}
setTomorrow();
</script>

【讨论】:

    猜你喜欢
    • 2020-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-03
    • 1970-01-01
    相关资源
    最近更新 更多