Iphone NSDate Conversion problem?

It looks like your date format string isn't taking the letter "T" into account – and you should probably be enclosing literal text between apostrophes, just to be safe. Try.

Up vote 1 down vote favorite share g+ share fb share tw.

In my graph Api for facebook.. I am getting this data.. from Json.. "updated_time" = "2011-05-17T14:52:16+0000"; and I am using this code to convert it into valid date format NSDateFormatter *df = NSDateFormatter alloc init autorelease; //2010-12-01T21:35:43+0000 df setDateFormat:@"yyyy-mm-ddHH:mm:ssZZZZ"; NSDate *date = df dateFromString:forTable valueForKey:@"updated_time" stringByReplacingOccurrencesOfString:@"T" withString:@""; df setDateFormat:@"eee MMM dd, yyyy hh:mm"; pastDate = df stringFromDate:date; NSLog(@"and the date string is %@",pastDate); and it is giving me this result in the console and the date string is Mon 01 17, 2011 08:22 though json value is giving me the date of May. This code is giving me the date January can anyone tell me what is happening here? Iphone objective-c ios nsdate nsdateformatter link|improve this question edited May 20 '11 at 7:06Nick Weaver13.5k21940 asked May 20 '11 at 6:45tzu.

Rahul719120 86% accept rate.

Also, the '+' might be causing problems, it looks like you parsed out the T. – Joe May 20 '11 at 7:04.

It looks like your date format string isn't taking the letter "T" into account – and you should probably be enclosing literal text between apostrophes, just to be safe. Try: df setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ssZZZZ".

It worked...Thanks...both are up :) – tzu. Rahul May 20 '11 at 7:19.

The dateFormat was wrong, it should be with capital Ms for the month: df setDateFormat:@"yyyy-MM-ddHH:mm:ssZZZZ".

It worked ..Thanks :) – tzu. Rahul May 20 '11 at 7:18.

Your code is perfectly valid only the lbtInDate. Text and lblOutDate. Text respect the date format.

If not your NSDate's will be null.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions