gpt4 book ai didi

iphone - 修改文件 IOS 的 UTF 时间

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:05:45 24 4
gpt4 key购买 nike

需要获取 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];
}

关于iphone - 修改文件 IOS 的 UTF 时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14101318/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com