Reputation: 3301
I am parsing the following string format: "29/09/2010 12:45:00" with the following code:
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"dd/MM/yyyy HH:mm:ss"];
NSDate *dateTime = [[df dateFromString:dateAndTime]];
But the NSDate object then contains the following: 2010/09/29 11:45:00
Does anyone have any idea why it is taking off an hour?
Many thanks for any help.
Upvotes: 2
Views: 426
Reputation: 243146
What time zone are you in? Unless otherwise specified, NSDateFormatter
assumes that the string it's parsing is in the GMT +0000
timezone. If you're in GMT -0100
(one hour west of GMT), then it's going to show the time as one hour off (since you're ignoring the time zone when printing).
Upvotes: 2