Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 893
NewXcoder Avatar asked Jan 10 '13 03:01

NewXcoder


1 Answers

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.

like image 68
Breakpoint Avatar answered Nov 08 '22 12:11

Breakpoint