How can I use NSDateFormatter to get the string “Yesterday”? [closed]

一曲冷凌霜 提交于 2019-12-23 07:38:18

问题


I want to format my NSDate so that a date that occurred yesterday will be displayed as "Yesterday'. Can this be done using NSDateFormatter?


回答1:


Use,

[dateFormatter setDoesRelativeDateFormatting:YES]

to indicate if an output of date components need to be printed in a phrase or not, as "Today", "Tomorrow" etc. The output phrases however, depend on the locale set for the dateFormatter

Read through the Managing Natural Language Support of the NSDateFormatter Class Reference for further details.



来源:https://stackoverflow.com/questions/14250235/how-can-i-use-nsdateformatter-to-get-the-string-yesterday

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!