gpt4 book ai didi

ios - 如何获取 NSDate 消息中显示的时间间隔,例如 2m,3h,星期二,2014-06-01

转载 作者:行者123 更新时间:2023-11-29 10:41:34 25 4
gpt4 key购买 nike

是否有框架或 API 提供从给定 NSDate 到当前 NSDate 的时间间隔,例如 2m、3h、Tuesday、2014-06-01。它广泛用于 iMessages 和 Mail App。它也被用在其他应用程序中,我只是在尝试为自己编写一个框架之前看看是否有一个框架。

最佳答案

我建议使用 this类别。这对您要查找的内容非常有帮助。

例如这行代码:

NSString *displayString = [NSDate stringForDisplayFromDate:date];

产生以下类型的输出:

 - ‘3:42 AM’ – if the date is after midnight today
- ‘Tuesday’ – if the date is within the last seven days
- ‘Mar 1’ – if the date is within the current calendar year
- ‘Mar 1, 2008’ – else ;-)

关于ios - 如何获取 NSDate 消息中显示的时间间隔,例如 2m,3h,星期二,2014-06-01,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24304162/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com