Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

arnieterm

macrumors regular
Original poster
Aug 28, 2008
201
0
Hi all
I am trying to generate an NSDate value by passing the below given string
to the setDateFormat method of NSDateFormatter
as show below
Code:
NSDateFormatter *dt=[[NSDateFormatter alloc]init];
	[dt setFormatterBehavior:NSDateFormatterBehavior10_4];
	[dt setDateFormat:@"yyyy-mm-dd HH:MM:ss +0000"];
When I make use of
dateFromString with the below given string
"2009-02-01 00:00:00 +0000", it does not generate a valid date
What's wrong with this date format?
Thanks
 
Hi all
I am trying to generate an NSDate value by passing the below given string
to the setDateFormat method of NSDateFormatter
as show below
Code:
NSDateFormatter *dt=[[NSDateFormatter alloc]init];
	[dt setFormatterBehavior:NSDateFormatterBehavior10_4];
	[dt setDateFormat:@"yyyy-mm-dd HH:MM:ss +0000"];
When I make use of
dateFromString with the below given string
"2009-02-01 00:00:00 +0000", it does not generate a valid date
What's wrong with this date format?
Thanks

You probably used invalid date format pattern.
Y = year
M = month
m = minute

So your date format should be: "YYYY-MM-dd HH:mm:ss +0000".

Cheers. :apple:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.