2

Tried converting NSString with the date 'Saturday 22 August 2015 17:30' to NSDate but it comes out with '2014-12-27 17:30:00 UTC'. I don't even care that the format comes out wrong, i just want it to convert it to NSDate correctly.

currentFixtures.timeDate is a NSString containing 'Saturday 22 August 2015 17:30' fixtureDate is an NSDate that comes back with '2014-12-27 17:30:00 UTC'

 NSDateFormatter *dateFormatFixture = [[NSDateFormatter alloc]init];
 [dateFormatFixture setDateFormat:@"EEEE d MMMM YYYY HH:mm"];
 [dateFormatFixture setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en-GB"]];
 [dateFormatFixture setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];


 NSDate *fixtureDate = [[NSDate alloc] init];
 fixtureDate = [dateFormatFixture dateFromString:currentFixture.timeDate];
Ben
  • 67
  • 4
  • 2
    Use `yyyy`, not `YYYY`. And the locale should be `en_GB`, not `en-DB`. – rmaddy Aug 12 '15 at 15:17
  • check this post [get current date as DD/MM/YYYY][1] [1]: http://stackoverflow.com/questions/27790657/ios-8-get-current-date-as-dd-mm-yyyy – Dovahkiin Aug 12 '15 at 15:18

1 Answers1

1

EEEE d MMMM yyyy H:m works, thanks to maddy

Ben
  • 67
  • 4