Search code examples
iphoneobjective-ccocoafilensfilemanager

File Attribute NSFileModificationDate returns time 5 hours after expected time in iPad application


Hello I'm using the following NSFileManager method in an iPad application:

- (NSDictionary *)attributesOfItemAtPath:(NSString *)path error:(NSError **)error

to get file attributes, then use the key NSFileModificationDate to get the latest file modification date/time. However, the date/time that it is returning me is 5 hours ahead of the date that I actually save the file which is what I see inside my "Finder" when viewing properties of the file.

I know a workaround/hack would be to knock 5 hours of the time I get back but I'd like to know why this is happening. Anybody know? Thanks.


Solution

  • Remember file timestamps are always in UTC, and the Finder compensates for whatever timezone you're currently in when displaying, so you have to do the same.