Existing time string obtained from the server:
@ "2016-12-05t12:21:37″
The difference between this and the generally obtained time string is that there is a T in the middle.
The NSDate method is obtained from this string as follows:
1.
NSDateFormatter *dateformatter = [NSDateFormatter new];
Dateformatter.dateformat = @ "Yyyy-mm-dd ' t ' HH:mm:ss";//Use date format with substring ' t '
NSDate *date = [dateformatter datefromstring:@ "2016-12-05t12:21:37"];
2.
nsmutablestring *mutablestringwitht = [[Nsmutablestring alloc] initwithstring:@ "2016-12-05t12:21:37"];
[Mutablestringwitht replacecharactersinrange:[mutablestringwitht rangeofstring:@ "T"] withString:@ ""];// Manually replace the time string with T with the @ ""
NSDateFormatter *dateformatter = [NSDateFormatter new];
Dateformatter.dateformat = @ "Yyyy-mm-dd HH:mm:ss";//Not with ' T ' date format
NSDate *date = [Dateformatter datefromstring:mutablestringwitht];