title: Difference between 'YYYY' and 'yyyy' in NSDateFormatter
body: <p>What is exact difference between 'YYYY' and 'yyyy'. I read in <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html#//apple_ref/doc/uid/TP40002369-SW1">this link</a>, it states that </p>
  
  <blockquote>
    <p>A common mistake is to use YYYY. yyyy specifies the calendar year
    whereas YYYY specifies the year (of “Week of Year”), used in the ISO
    year-week calendar. In most cases, yyyy and YYYY yield the same
    number, however they may be different. Typically you should use the
    calendar year.</p>
  </blockquote>
  
  <p>But when I try to use </p>
  
  <pre><code>NSString *stringDate = @"Feb 28, 2013 05:30pm";
  NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  [dateFormatter setDateFormat:@"MMM dd, yyyy hh:mma"];
  NSDate *date=[dateFormatter dateFromString:stringDate];
  NSLog(@"Date 1 : %@",date); //2013-02-28 12:00:00 +0000
  
  NSString *stringDatee = @"Feb 28, 2013 05:30pm";
  NSDateFormatter *dateFormatterr = [[NSDateFormatter alloc] init];
  [dateFormatterr setDateFormat:@"MMM dd, YYYY hh:mma"];
  NSDate *datee=[dateFormatterr dateFromString:stringDatee];
  NSLog(@"Date 2 : %@",datee); //2013-01-05 12:00:00 +0000
  
  NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
  [dateFormat setDateFormat:@"MMM dd, YYYY hh:mma"];
  NSString *dateString = [dateFormat stringFromDate:datee];
  NSLog(@"date 3 : %@", dateString); //Jan 05, 2013 05:30PM
  </code></pre>
  
  <p>As here, result to <code>date</code> and <code>datee</code> different, which I understood, but why result of date 2 and date 3 are different? As I am creating date from string and reversing same to string again, but output mismatches?</p>
  
  <p>Has anybody knows reason about same?. Though it specifies week of year, still I should get result same.</p>
  
  <p>Thanks..</p>
  
  <p>EDIT :-</p>
  
  <p>If I code</p>
  
  <pre><code>NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
  [dateFormat setDateFormat:@"MMM dd, YYYY hh:mma"];
  NSString *dateString = [dateFormatterr stringFromDate:[NSDate date]];
  NSLog(@"date: %@", dateString); //Feb 28, 2013 04:37PM
  </code></pre>
  
  <p>If results me proper result, but same which I pass as string to date I get <code>2013-01-05 12:00:00 +0000</code>, check date 2 of NSLog, Strange result, why?</p>