objective c - How can i convert NSDate to NSString ios? -



objective c - How can i convert NSDate to NSString ios? -

i'm receiving date server next format "/date(1413374176217)/" . tried this

nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"dd-mm-yyyy"] nsdate *datefromstring = [[nsdate alloc] init]; datefromstring = [dateformatter datefromstring:date]; nslog(@"datefromstring = %@",datefromstring);

but doesn't work.

how can convert string?

try this.

nsstring *actdate = @"/date(1326067200000)/"; nsstring *ndate = [[[[actdate componentsseparatedbystring:@"("] objectatindex:1] componentsseparatedbystring:@")"] objectatindex:0]; nsdate *date = [nsdate datewithtimeintervalsince1970:([ndate doublevalue] / 1000)];

ios objective-c nsstring nsdate nsdateformatter

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -