I had this code working for iOS5, but I just teste
NSDate *now = [NSDate date];
NSString *strDate = [[NSString alloc] initWithFormat:@"%@",now];
Does anyone know easy solution of rewriting this. The format of the date should be dd mm yyyy
Try this one , Definitely will get Proper solution:
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd"];//as per your requirement
NSDateFormatter *timeFormat = [[NSDateFormatter alloc] init];
[timeFormat setDateFormat:@"HH:mm:ss"]; //as per your requirement
NSDate *now = [[NSDate alloc] init];
NSString *theDate = [dateFormat stringFromDate:now];
NSString *theTime = [timeFormat stringFromDate:now];
NSLog(@"theDate:%@ "theTime:%@" , theDate, theTime);