【问题标题】:Can NSDateFormatter format a date relative to a time other than the current time?NSDateFormatter 可以格式化相对于当前时间以外的时间的日期吗?
【发布时间】:2015-11-16 21:51:59
【问题描述】:

在打开doesRelativeDateFormatting 的情况下使用NSDateFormatter 时,所有相关格式似乎都与当前系统时间相关。我想用相对格式来格式化日期,例如“今天”或“明天”,但相对于任意“当前”时间而不是实际时间。

例如,我想指定 2015 年 11 月 2 日的 NSDate,将 2015 年 11 月 1 日作为“当前”时间,并将其格式化为“明天”而不是“2015 年 11 月 2 日”。 NSDateFormatter可以这样做吗?

【问题讨论】:

    标签: cocoa nsdateformatter


    【解决方案1】:

    它总是相对于系统日期。对不起。

    但是

    https://github.com/billgarrison/SORelativeDateTransformer 可能能够做到这一点。也许你可以从那里得到代码

    【讨论】:

    • 那个链接并不能真正满足我的需要,所以我最终写了自己的东西。答案肯定是否定的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-14
    • 1970-01-01
    • 2015-06-07
    • 1970-01-01
    • 1970-01-01
    • 2010-11-14
    • 2010-11-10
    相关资源
    最近更新 更多