Question

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

Was it helpful?

Solution

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];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top