NSDateFormatter for IPhone

Discussion in 'iOS Programming' started by arnieterm, Oct 9, 2008.

  1. arnieterm macrumors regular

    Aug 28, 2008
    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
    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?
  2. annguyen macrumors newbie

    Oct 2, 2008
    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:

Share This Page