Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UTF Time for modified File IOS

Need to get the last modified time for IOS application inside the document folder with UTF time format?

like image 583
kumar Avatar asked Nov 17 '25 14:11

kumar


1 Answers

Try following code, that will help

+ (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];
}
like image 144
Codesen Avatar answered Nov 19 '25 05:11

Codesen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!