Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6709983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:56:48+00:00 2026-05-26T07:56:48+00:00

I am comparing the date when a file was last modified for two files,

  • 0

I am comparing the date when a file was last modified for two files, one local and one on Amazon S3 server. I am using the AWS IOS SDK framework and can successfully request and receive response from the S3 server but I have trouble understanding the format of the returned s3 date.

On my local machine the date format for lastModified is “2011-07-21 18:43:15 -0400” while for the file residing on the S3 server it is “2011-10-15T16:25:49.000Z”.

My local info is obtained using:

    NSFileManager *fm  = [NSFileManager defaultManager];
    NSDictionary *attr = [fm attributesOfItemAtPath:filePath error:nil];
    NSDate *localDate  = [attr objectForKey:NSFileModificationDate];

while my S3 info is obtained using

    for (S3ObjectSummary *object in [listObjectsResult objectSummaries]) {
       NSDate *s3date = [object lastModified];
    }

Does anyone know if I can convert the date for the S3 file to a format that I can use to compare these two dates using:

    NSTimeInterval deltaSeconds = [s3Date timeIntervalSinceDate: localDate];

or am I doing something wrong here? Right now my program crashes with

    [NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x200351360. 

probably because the s3 date format is not in proper format. I am quite new to using the AWS S3 SDK so all help is greatly appreciated. If anyone also knows of some good tutorials for this framework (apart from the demo code that comes with it), that would be great. Cheers, Trond

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:56:48+00:00Added an answer on May 26, 2026 at 7:56 am

    It looks to me as [object lastModified] simply returns a NSString and not an NSDate object, as stated in the documentation.

    NSDateFormatter can be used in this case to create a NSDate object from the string:

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    
    [dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'+'mm':'ss.SSS'Z'"];
    
    NSDate *s3date = [dateFormatter dateFromString:[object lastModified]];
    
    [dateFormatter release];
    

    The Date Formatting guide has lots of handy examples. You may need to tweak the format string slightly as i have not tested it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the next problem up from this one: Comparing date ranges The solution
Hi iam using the following code for comparing the entered date with current date...
When comparing two strings in c# for equality, what is the difference between InvariantCulture
When comparing two objects (of the same type), it makes sense to have a
I'm comparing between two techniques to create partitioned tables in SQL 2005. Use partitioned
I want to override this method for comparing two objects. -(BOOL)isEqual:(id)object Calling function -(void)overridemethod(
I am comparing two dates and trying to determine the max of the two
I need a PHP script that will find the date of the oldest file
Possible Duplicates: Comparing dates How to compare two dates in Objective-C i want to
I am trying to copy files from one directory to another and test based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.