iphone - DateFormat Conversion -


i have string in format:

2012-11-08t13:50:05.284-08:00 

i need convert format:

november 8, 2012 1:50 pm, 

i have identified pattern of date yyyy-mm-ddthh:mm:ss.stzd, this:

nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:@"yyyy-mm-ddthh:mm:ss.stzd"];    nsdate *date = [dateformat datefromstring:@"2012-11-08t13:50:05.284-08:00"];  [dateformat setdateformat:@"mmmm dd, yyyy hh:mm a"]; nsstring *newdatestr = [dateformat stringfromdate:date]; 

could please tell me what's wrong here?
is format template correct or not?

try this:as getting valid output.

 nsdateformatter *dateformat = [[nsdateformatter alloc] init];  [dateformat setdateformat:@"yyyy-mm-dd't'hh:mm:ss.s'-'s':'s"];   nsdate *date = [dateformat datefromstring:@"2012-11-08t13:50:05.250-8:00"];   [dateformat setdateformat:@"mmmm dd, yyyy hh:mm a"];   nsstring *newdatestr = [dateformat stringfromdate:date];   nslog(@"newdatestr %@", newdatestr); 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -