我正在尝试设置格式为 HH:mm:dd 的计时器。
例如:时间将显示“22:25:05”或“00:04:22”,还剩荷鲁斯/分钟/秒。
我设法让它显示时间,但无法使计时器工作并进行实时倒计时。
我如何设置一个可以使用这种格式的计时器?谢谢
我的代码:
var now = moment();
var startDate = "16/03/2016 00:00:00";
var endDate = "16/03/2016 23:59:59";
diffHours = moment.utc(moment(endDate,"DD/MM/YYYY HH:mm:ss").diff(moment())).format("HH");
diffMinutes = moment.utc(moment(endDate,"DD/MM/YYYY HH:mm:ss").diff(moment())).format("mm");
diff = moment.utc(moment(endDate,"DD/MM/YYYY HH:mm:ss").diff(moment())).format("HH:mm:ss");
var percentage_complete = (now - moment(startDate,"DD/MM/YYYY HH:mm:ss")) / (moment(endDate,"DD/MM/YYYY HH:mm:ss") - moment(startDate,"DD/MM/YYYY HH:mm:ss")) * 100;
var percentage_rounded = (Math.round(percentage_complete * 100) / 100);
jQuery("input.dial").attr("value",percentage_rounded);
jQuery(".dial").knob({
'readOnly':true,
'draw' : function () {
jQuery(this.i).val(diff);
}
});