獲取最後一次修改IOS應用文件夾的時間,要求輸出UTF時間格式,如能幫助,十分感謝。
這應該就是你要的
+ (NSString*) fnGetModifiedTime: (NSString*)inFolderPath {
NSFileManager* fm = [NSFileManager defaultManager];
NSDictionary* attrs = [fm attributesOfItemAtPath:inFolderPath error:nil];
int theDirModified = 0;
if (attrs != nil) {
NSDate *date = (NSDate*)[attrs objectForKey: NSFileModificationDate];
NSDate* theGlobalDate = [self toGlobalTime:date];
theDirModified = [theGlobalDate timeIntervalSince1970];
}
return [NSString stringWithFormat:@"%i",theDirModified];
}
+(NSDate *) toGlobalTime:(NSDate*) inDate
{
NSTimeZone *tz = [NSTimeZone defaultTimeZone];
NSInteger seconds = -[tz secondsFromGMTForDate: inDate];
return [NSDate dateWithTimeInterval: seconds sinceDate: inDate];
}