Hello Everyone!!
Need Your help.
I have an issue with date Formatter.
I have Two string. one string contains date in form of MM/dd/yyyy; and second string contains time in form of hh:mm a.
Now i want to concatenate this two strings and want output as a new strings in form of yyyy-MM-dd HH:mm:ss.
I have tried following but unfortunately it doesn't work more.
-(NSString *)ConcateDateAndTime:(NSString *)date Time:(NSString *)time{
date = [date stringByAppendingFormat:@" %@",time];
NSDateFormatter *formater = [[NSDateFormatter alloc]init];
[formater setDateFormat:@"MM/dd/yyyy hh:mm aa"];
NSDate *dt = [NSDate date];
dt = [formater dateFromString:date];
NSDateFormatter *formater1 = [[NSDateFormatter alloc]init];
[formater setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *temp;
temp = [formater1 stringFromDate:dt];
return temp;
}
Kindly guide me to solve this issue.
Looking forwards.
Thank You,
Arun Thakkar.