dtdt0454 2015-09-06 18:10
浏览 70
已采纳

Jquery倒计时插件,来自Mysql数据库的日期

I'm trying to modifie the JS script so I can get the date from a database instead of typing it manually. I don't really know how to get right format on the date. The plugin only use days, hours, minutes, seconds.

Is there someone that can help me?

Jquery countdown plugin

Original:

$(function () {
var austDay = new Date();
austDay = new Date(austDay.getFullYear() + 1, 1 - 1, 2);
$('#defaultCountdown').countdown({until: austDay});
$('#year').text(austDay.getFullYear());
});

</script>

Modified:

<?php $waa = '1441894898' ?>

<script>

$(function () {
var austDay = <?php echo json_encode($waa); ?>;
$('#defaultCountdown').countdown({until: austDay});
});
</script>
  • 写回答

2条回答 默认 最新

  • dpgbh20688 2015-09-06 18:22
    关注

    The plugin don't only use years, months, etc..., but a javascript Date (reference here) instance. So if your $waa variable is the date from what you want to count down, and it is in milliseconds, the var austDay = new Date(<?php echo $waa; ?>); code should work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?