开发者

How to show last login time as "Logged <sometime> ago" in a toolbar?

开发者 https://www.devze.com 2023-02-04 16:40 出处:网络
I want to show the time difference between last login time & current login time. That means, the message should be in the form like \"Logged 5 mins ago\". This message will be showed in a toolbar

I want to show the time difference between last login time & current login time. That means, the message should be in the form like "Logged 5 mins ago". This message will be showed in a toolbar which placed in a tableview. How can i do it?

Another question is, even开发者_JS百科 though i show the message, for each a minute, can i refresh the toolbar to get the updated time?


Store the last login time in userDefaults,

Calculate the time difference by,

NSTimeInterval timeDiff = [loginTime timeIntervalSinceNow];
int diff=trunc(timeDiff/(60*60));

Display the value in toolbar

0

精彩评论

暂无评论...
验证码 换一张
取 消