Friday, May 10, 2013

NSDateFormatter setDefaultDate example ios


setDefaultDate:

Sets the default date for the receiver.
- (void)setDefaultDate:(NSDate *)date
Parameters
date
The default date for the receiver.


Example of [NSDateFormatter setDefaultDate]

NSDate *now = [NSDate date];

NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"hh:mm a"];
[formatter setDefaultDate:now];

NSDate *theDate = [formatter dateFromString:@"11:13 AM"];
NSComparisonResult theResult = [theDate compare:now];

Example of [NSDateFormatter setDefaultDate]
[dateFormat setDefaultDate:today];