如何设置倒计时脚本的当前日期?

时间:2014-05-05 20:22:48

标签: javascript html html5 datetime

您好我只想知道如何将倒计时的日期自动设置为当前的数据,这是脚本:

<script>


jQuery(document).ready(function () {


    function callback() {
        alert("finish");
    }
    $("#flipit").coffeetime({
        /* COUNTDOWN SETTINGS */
        message: message, // the message array with the array keys as percent values
        startYear: 2013,
        startMonth: 8,
        startDay: 1,
        endYear: 2015,
        endMonth: 0,
        endDay: 0,
        soundControlCssClass: 'icon sound margin-top-20  body-google-font',
        messageBoxId: "percent-message",
        callbackFinish: callback,
    });


    $(".flip-title-subheading").html("was created in: " + new Date() + " and we`ll finish after: " + window.endDate);

});
jQuery(document).ready(function () {
    setTimeout(function () {
        $(".flip-container").animate({
            "height": 105 + "px"
        }, 1000, "swing");
    }, 1000);
});

我想知道如何将startYear,startMonth,startDay设置为自动在当前日期。

1 个答案:

答案 0 :(得分:0)

jQuery(document).ready(function () {


    function callback() {
        alert("finish");
    }
    var dt = new Date();
    $("#flipit").coffeetime({
        /* COUNTDOWN SETTINGS */
        message: message, // the message array with the array keys as percent values
        startYear: dt.getFullYear(),
        startMonth: dt.getMonth() + 1,
        startDay: dt.getDate(),
        endYear: 2015,
        endMonth: 0,
        endDay: 0,
        soundControlCssClass: 'icon sound margin-top-20  body-google-font',
        messageBoxId: "percent-message",
        callbackFinish: callback,
    });


    $(".flip-title-subheading").html("was created in: " + new Date() + " and we`ll finish after: " + window.endDate);

});
jQuery(document).ready(function () {
    setTimeout(function () {
        $(".flip-container").animate({
            "height": 105 + "px"
        }, 1000, "swing");
    }, 1000);
});