Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>1) You should use <code>yyyy</code>, not <code>YYYY</code>. <code>YYYY</code> stands for year in "Week of Year" based calendars - it may not always be the same value as calendar year. See the <a href="http://www.unicode.org/reports/tr35/tr35-25.html#Date_Format_Patterns" rel="nofollow">documentation</a>.</p> <p>2) Format to parse "Monday 02,Dec 2013" should be "EEEE dd,MMM yyyy"</p> <p>EDIT 3) Forget to say about locale — device with non-english locale will fail to parse "Monday 02,Dec 2013" (because of "Monday" and "Dec") if you will not set the locale for the date formatter explicitly:</p> <pre><code>NSDateFormatter *dateFormatterForGettingDate = [[NSDateFormatter alloc] init]; dateFormatterForGettingDate.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; [dateFormatterForGettingDate setDateFormat:@"EEEE dd,MMM yyyy"]; </code></pre> <p>I think, this should work:</p> <pre><code>-(void)dateSelectedInPickerView:(NSString *)dateSelected{ NSDateFormatter *dateFormatterForGettingDate = [[NSDateFormatter alloc] init]; dateFormatterForGettingDate.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; [dateFormatterForGettingDate setDateFormat:@"EEEE dd,MMM yyyy"]; // Parse the string representation of the date i.e Monday 2,Dec 2013 NSDate *dateFromStr = [dateFormatter dateFromString:dateSelected]; NSLog(@"date selected : %@",dateFromStr); NSDateFormatter *tempFormatter=[[NSDateFormatter alloc]init]; [tempFormatter setDateFormat:@"yyyy-MM-dd"]; self.reservationDateSelected=[tempFormatter stringFromDate:dateFromStr]; NSLog(@"date Selected : %@",self.reservationDateSelected); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload