Safari Safari - 8 months ago 36
Objective-C Question

get time and date by NSDate

how can I retrieve the date and time from a NSDate.
I want to see them separately.

NSDate *localDate = [NSDate date];
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc]init]autorelease];
dateFormatter.dateFormat = @"MM/dd/yy";

NSString *dateString = [dateFormatter stringFromDate: localDate];

NSDateFormatter *timeFormatter = [[[NSDateFormatter alloc]init]autorelease];
timeFormatter.dateFormat = @"HH:mm:ss";

NSString *dateString = [timeFormatter stringFromDate: localDate];

There are many many different ways to represent the date and time so check NSDateFormatter for more info.