The output comes, for example: 17-10-1990 18:30:00 +0000. When we retrieve the value in NSDateFormatter the day is changed to 16-10-1990. No error comes.
NSDateFormatter *sdayFormat = [[NSDateFormatter alloc] init];
[sdayFormat setDateF开发者_JS百科ormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *sdayString = [sdayFormat stringFromDate:datePicker.date];
please help me. I'm new in iphone developer.
to see how to set dateFormatter go to this link - NSDateFormatter and yyyy-MM-dd
and to see the list of all possible formats go to this link
Check this out!
NSString *tDate = @"17-10-1990 18:30:00 +0000";
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd-MM-yyyy HH:mm:ss Z:"];
NSDate *fDate = [dateFormat dateFromString:tDate];
NSLog(@"Given date :%@ - Converted Date :%@",tDate,fDate);
use this link as reference for any date related operations
http://www.stepcase.com/blog/2008/12/02/format-string-for-the-iphone-nsdateformatter/
Hope this helps
精彩评论