ios - How to get date in "yyyy-MM-dd'T'HH:mm:ss.SSSZ" format? -
i have date in format 2014-09-20 04:45:20 +0000 , need convert yyyy-mm-dd't'hh:mm:ss.sssz format.i tried following code
nsdateformatter * formatter = [[nsdateformatter alloc] init]; [formatter setdateformat:@"yyyy-mm-dd't'hh:mm:ss.sss'z'"]; nsdate *date = [formatter datefromstring:@"2014-09-20 04:45:20 +0000"]; nslog(@"%@",date);
but date giving me null value..
i geting 2014-09-20 04:45:20 +0000 time picker anythg needs done on picker side me.
try this:
nsstring *astrdate = @"2014-09-20 04:45:20 +0000"; nsdateformatter *adateformatter = [[nsdateformatter alloc] init]; adateformatter.dateformat = @"yyyy-mm-dd hh:mm:ss z"; nsdate *adate = [adateformatter datefromstring:astrdate]; adateformatter.dateformat = @"yyyy-mm-dd't'hh:mm:ss.sss'z'"; nslog(@"%@",[adateformatter stringfromdate:adate]);
Comments
Post a Comment