if I try:
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyyMMdd"];
and
[formatter dateFromString:@"20120423"];
My new NSDate object will be: 2012 04 22. Why one day less?
Thank
For those who looks for swift 3 version
let formatter = DateFormatter()
formatter.timezone = TimeZone(abbreviation: "GMT")
formatter.dateFormat = "yyyyMMdd"
formatter.date(from: "20120423")
You have problems with time zone and it can be solved by adding this line of code:
formatter.timeZone = [NSTimeZone timeZoneWithName:@"GMT"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With