0

Here is the code I used to change the date format.

        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        [formatter setDateFormat: @"YYYY-MM-dd HH:mm"];
        NSString *endDate = [formatter stringFromDate:[NSDate date]];

----------Output---------------

(lldb) po [NSDate date] 2015-12-27 05:24:18 +0000

(lldb) po endDate 2016-12-27 11:09

This issue was fixed when I used @"yyyy-MM-dd HH:mm" but I did not understand why a whole year is changed when week based year is used. This issue also occurs for date Dec (27-31) 2020.

kb920
  • 3,039
  • 2
  • 33
  • 44
  • Because the last days of a year can belong to the first week of the next year. – gnasher729 Mar 23 '16 at 07:11
  • It would be ok if it had shown first week of the next year, but it is showing last month and last date. i.e no change in date. Please take a look at output in question. – manoj shrestha Mar 27 '16 at 05:36

0 Answers0