Getting human readable relative times and dates from a unix timestamp?

前端 未结 6 470
挽巷
挽巷 2021-01-14 00:32

Starting with a unix timestamp like 1290529723, how would I (assuming gmt) get the information on whether it is:

  • today (if so, what time)

  • i

6条回答
  •  遥遥无期
    2021-01-14 01:04

    Convert it to an NSDate with:

    + (id)dateWithTimeIntervalSince1970:(NSTimeInterval)seconds
    

    Then compare to other dates with:

    * – compare:
    * – earlierDate:
    * – isEqual: (NSObject protocol)
    * – laterDate:
    

提交回复
热议问题