views:

19

answers:

1

Hello

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.

+1  A: 

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).

Dave DeLong