0
我有一個從Date()。getTime()獲取數字的單擊函數。我想採取這個數字,並在我的觀點倒計時他。如何從JavaScript中的Date()。getTime()中創建倒計時?
我只使用JavaScript與Ionic框架1x。
var currentDate = new Date().getTime();
console.log(currentDate);
var secondDate = new Date(item.date).getTime();
console.log(secondDate);
secondDate = new Date(secondDate).getSeconds();
console.log(secondDate);
$scope.countdown = secondDate;
謝謝czosel!它的工作完美。大約在那個時候,有一個簡單的方法來倒轉倒計時? –
不客氣!要倒轉倒計時,您可以計算當前日期和倒計時日期之間的差異,並將該值與範圍綁定。 –