ios - Converting NSString into NSDAte once again -



ios - Converting NSString into NSDAte once again -

i have label :

_labelcell.text = [2014-06-22 20:27:48 +0000];

what want convert string nsdate can format : eeee dd mm yyyy

i seek :

// convert date nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:@"yyyy-mm-dd't'hh:mm:ss'+0000'"]; nsdate *dte = [dateformat datefromstring:str]; nslog(@"date: %@", dte);

but give me null nsdate

can help me on little thing ?

thank much.

your date formatter expecting t in between date , time. returns null because there string has space instead of t.

you're missing space before timezone.

fix 2 issues, , should work:

dateformat.dateformat = @"yyyy-mm-dd hh:mm:ss '+0000'";

beware might give wrong date, because of time zone issues. test out, , if doesn't work adjust accordingly dateformat.timezone = ...

ios objective-c nsstring nsdate

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -