3
需要在UTF時間格式的文檔文件夾中獲取IOS應用程序的最後修改時間?修改文件的UTF時間IOS
需要在UTF時間格式的文檔文件夾中獲取IOS應用程序的最後修改時間?修改文件的UTF時間IOS
下面的代碼試試,這將有助於
+ (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];
}