Date formatters examples in Objective-C
Enviado por admin en
iPhone Dev en la fecha 12 20th, 2009 |
sin comentarios
Here are several simple examples for displaying date information:
// Date: 10/29/08
NSDate *today
= [NSDate dateWithTimeIntervalSinceNow
:0
];
NSDateFormatter *dateFormat
= [[[NSDateFormatter alloc
] init
] autorelease
];
[dateFormat setDateStyle
:NSDateFormatterShortStyle
];
NSString *dateString
= [dateFormat stringFromDate
:today
];
NSLog
(@"Date: %@", dateString
);
// Date: 10/29/2008 08:29PM
NSDate *today
= [NSDate date
];
NSDateFormatter *dateFormat
= [[NSDateFormatter alloc
] init
];
[dateFormat setDateFormat
:@"MM/dd/yyyy hh:mma"];
NSString *dateString
= [dateFormat stringFromDate
:today
];
NSLog
(@"Date: %@", dateString
);
[dateFormat release
];
No comments yet.
RSS feed for comments on this post. TrackBack URL
You must be logged in to post a comment.
---