ios - NSDate Issue While Creating it from NSString -


i have seen many solutions , tried since last 2 hours. posting code. seeing log fine nsstring contains date.

but when tried convert nsdate. it's return , logging null.

here code

nsdateformatter *formatter = [[nsdateformatter alloc]init];  nsstring *str = @"2014-10-28 00:00:00 am";     nslog(@"date %@",str);   ////showing string date  [formatter settimezone:[nstimezone timezonewithname:@"gmt"]]; [formatter setlocale:[[nslocale alloc] initwithlocaleidentifier:@"en_us"]]; [formatter setdateformat:@"yyyy/mm/dd hh:mm:ss"];  nsdate *dater = [formatter datefromstring:str]; nslog(@"dater %@",dater);     ////showing null log  

thanks in advance.

change one:

[formatter setdateformat:@"yyyy-mm-dd hh:mm:ss a"]; 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

qt - How to embed QML toolbar and menubar into QMainWindow -