Showing posts with label NSDateFormatterExamples. Show all posts
Showing posts with label NSDateFormatterExamples. Show all posts

Thursday, July 14, 2011

Date Formatter Examples

NSDateFormatter

To save you some time, here are several simple examples for displaying date information:

// <strong>Output ->  Date: 10/29/08</strong>
 NSDate *today = [NSDate dateWithTimeIntervalSinceNow:0];
 NSDateFormatter *dateFormat = [[[NSDateFormatter alloc] init] autorelease];
 [dateFormat setDateStyle:NSDateFormatterShortStyle];
 NSString *dateString = [dateFormat stringFromDate:today];
 NSLog(@"Date: %@", dateString);