Help with countdown jquery script to accept unix timestamp as input
I try to modify the keith-wood countdown timer to accept a future unix timestamp and hide the days.
To hide the days you use $('#noDays').countdown({until: liftoffTime, format: 'HMS'});
as the example at http://keith-wood.name/countdown.html under the tab Formats1 says.
I didn't manage yet to make it work. How 开发者_如何学Pythonto modify the code to get a unix timestamp as input and hide the days?
Standard timer
<script type="text/javascript">
$(function () {
var austDay = new Date();
austDay = new Date(austDay.getFullYear() + 1, 1 - 1, 26);
$('#defaultCountdown').countdown({until: austDay});
$('#year').text(austDay.getFullYear());
});
</script>
My try to have as input a unix timestamp (does not work)
<script type="text/javascript">
$(function () {
var austDay = new Date();
austDay = new Date(<?php echo $unixtimestamp; ?>*1000);
$('#defaultCountdown').countdown({until: austDay});
$('#year').text(austDay.getFullYear());
});
</script>
You can use the setTime()
function:
var austDay = new Date();
austDay.setTime(<?php echo $unixtimestamp * 1000; ?>);
Edit: added * 1000
to go from unix timestamp to javascript timestamp...
精彩评论