/ Published in: Objective C
                    
                                        
This snippet is used to covert any date to days like today, tomorrow, 2 days ago, 2 weeks ago or even 1 years ago.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
{
NSCalendarUnit units = NSCalendarUnitDay | NSCalendarUnitWeekOfYear |
NSCalendarUnitMonth | NSCalendarUnitYear;
// if `date` is before "now" (i.e. in the past) then the components will be positive
fromDate:date
options:0];
if (components.year > 0) {
} else if (components.month > 0) {
} else if (components.weekOfYear > 0) {
} else if (components.day > 0) {
if (components.day > 1) {
} else {
return @"Yesterday";
}
} else {
return @"Today";
}
}
URL: http://apptraitsolutions.com
Comments
 Subscribe to comments
                    Subscribe to comments
                
                