title: How to get date and time in format like - [Today 10:01:20], [08-jan-17 11:20:51] etc?
body: <p>I am working on chat apps and I want to send date/time in particular format like Today, yesterday with date. How can I display according to this format?</p>
  
  <pre><code>  - (NSString *)relativeDateStringForDate:(NSDate *)date
     {
        NSCalendarUnit units = NSCalendarUnitDay | NSCalendarUnitWeekOfYear | 
                         NSCalendarUnitMonth | NSCalendarUnitYear;
  
      NSDateComponents *components = [[NSCalendar currentCalendar] components:units
                                                                 fromDate:date
                                                                    toDate:[NSDate date]
                                                                  options:0];
    if (components.year &gt; 0) {
       return [NSString stringWithFormat:@"%ld years ago", (long)components.year];
     } else if (components.month &gt; 0) {
      return [NSString stringWithFormat:@"%ld months ago", (long)components.month];
     } else if (components.weekOfYear &gt; 0) {
      return [NSString stringWithFormat:@"%ld weeks ago", (long)components.weekOfYear];
     } else if (components.day &gt; 0) {
      if (components.day &gt; 1) {
           return [NSString stringWithFormat:@"%ld days ago", (long)components.day];
      } else {
          return @"Yesterday";
      }
     } else
       {
           return @"Today";
       }
     }
  </code></pre>
  
  <p>I am using above function to get date but I want date time in combined string. So how to pass date/time combine to the above method? Is it possible to send a date time string to this method?</p>