我试图使用primefaces扩展计时器...假设我设置超时是172439221 ...
当我用户格式化HH:mm:ss时,计时器无法显示47:53:59 ...
所以我尝试创建像这样的javascript函数
<script type="text/javascript">
function formatInterval(value) {
var diffSeconds = value / 1000 % 60;
var diffMinutes = value / (60 * 1000) % 60;
var diffHours = value / (60 * 60 * 1000) % 24;
var diffDays = value / (24 * 60 * 60 * 1000);
if (diffDays > 0) {
diffHours = diffHours + (diffDays * 24);
}
return Math.floor(diffHours) + ":" + Math.floor(diffMinutes) + ":" + Math.floor(diffSeconds);
}</script>
和这样的计时器
<pe:timer
update=":globalMessages createOrderButton" formatFunction="return formatInterval(value);"
timeout="#{orderPendingBacking.calculateCountDownTimeNoLimit(pending.orderTime)}"
listener="#{orderPendingBacking.onTimeout()}"/>
计时器错了......应该是47:53:59,计时器没有倒计时......
请帮助我... thx
我改变了我的javascript代码
<script type="text/javascript">
function formatInterval(value) {
var diffSeconds = value / 1000 % 60;
var diffMinutes = value / (60 * 1000) % 60;
var diffHours = value / (60 * 60 * 1000) % 24;
var diffDays = value / (24 * 60 * 60 * 1000);
var days = Math.floor(diffDays);
var hours = Math.floor(diffHours);
if (days > 0) {
hours = hours + (days * 24);
}
return hours + ":" + Math.floor(diffMinutes) + ":" + Math.floor(diffSeconds);
}
</script>
现在计时器显示正确值47:53:59 ......但计时器仍未倒计时