I am using the below code:
NSDateFormatter *dateFormatter = [[NSDateForm开发者_Python百科atter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterFullStyle];
NSDate *today=[NSDate date];
NSString *string = [dateFormatter stringFromDate:today];
NSLog(@"%@",string);
[dateFormatter release];
This will not give me this format 03/20/11 11:24 AM(MONTH/DATE/YEAR HOUR:MIN), if i convert system date and time so the converted string should have such type of information 03/20/11 11:24 AM(MONTH/DATE/YEAR HOUR:MIN).? What should i do?
you should set the date format as,
[dateFormat setDateFormat:@"dd/MM/YYYY hh:mm a"];
Try doing this and u will get the format
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MM/dd/yy HH:mm"];
NSDate *today=[NSDate date];
NSString *string = [formatter stringFromDate:today];
NSLog(@"%@",string);
[formatter release];
Good Luck!
精彩评论