Return to Snippet

Revision: 40674
at February 5, 2011 02:11 by BenClayton


Initial Code
Using Time and Date Formatting

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd"];

NSDateFormatter *timeFormat = [[NSDateFormatter alloc] init];
[timeFormat setDateFormat:@"HH:mm:ss"];

NSDate *now = [[NSDate alloc] init];

NSString *theDate = [dateFormat stringFromDate:now];
NSString *theTime = [timeFormat stringFromDate:now];

NSLog(@"\n"

          "theDate: |%@| \n"
          "theTime: |%@| \n"
          , theDate, theTime);

[dateFormat release];
[timeFormat release];
[now release];

Initial URL

                                

Initial Description

                                

Initial Title
NSDateFormatter Examples

Initial Tags

                                

Initial Language
Objective C