获取最后一次修改IOS应用文件夹的时间,要求输出UTF时间格式,如能帮助,十分感谢。
1条回答
- lanhailvcao 2013-01-06 06:22关注
这应该就是你要的
+ (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]; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报