需求:
cell中倒計時顯示,到期重新整理介面,超時資料消失。後端提供訂單生成時間戳createdtime。
計算:到期時間 = 訂單生成時間+後端訂單預留時間
剩餘時間 = 到期時間 - 現在時間
剩餘時間的年,月,日,時,分,秒都小於等於0時即為超時失效。
工具使用:countdown
//匯入檔案,鏈結文章末尾
#import "countdown.h"
@property (nonatomic , strong) countdown *countdown;
//輪詢初始化
self.countdown = [[countdown alloc] init];
__weak __typeof(self) weakself= self;
[self.countdown countdownwithper_secblock:^];
//輪詢並對cell進行賦值
- (void)updatetimeinvisiblecells
}//計算時間差
- (nsstring *)getnowtimewithstring:(nsstring *)atimestring
if (days) else if(hours)else
return [nsstring stringwithformat:@"剩餘時間 %@:%@", minutesstr,secondsstr];
}
感謝文明大佬的技術支援:countdown
參考文章:
js根據時間戳倒計時
根據後台給的時間戳,是活動結束時間戳!這裡我們就要根據當前的時間來和結束時間計算一共有多長時間!要看清楚後台給的時間戳是多少位的,有的給到了毫秒,有的給到了秒 10位 function getrtime endtime if parseint h 10 if parseint m 10 if par...
時間倒計時
一 技術要點 做乙個 分鐘 秒 根據不同的初始時間倒計時到 00 00 的效果 1 取得雙標籤元素的內容如取這是我的 中的 這是我的 2 根據特定字元分割字串例如 35 28 根據 把字串分為兩部分35與28 3 把帶有數字的string型別轉變為int型別的資料 4 多個if else巢狀的使用 ...
時間倒計時
關於倒計時時間的計算 當前的時間 一小時之後的時間 時間差 而當前的時間一直地在增加,那麼時間差也就會縮小 從而達到倒計時的效果 關於時間格式的計算 var now new date gettime var end new date 2016 7 26 22 40 gettime 因為1000毫秒是...