• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: getting last accessed date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting last accessed date


  • Subject: Re: getting last accessed date
  • From: Joar Wingfors <email@hidden>
  • Date: Thu, 07 Jul 2011 22:04:43 -0700

Hello Rick,

The access date on a file is updated very frequently. I think that stat:ing the file is enough, and that happens all the time.

If what you're looking for is the last *opened* date of the file, I think that your best bet is the kMDItemLastUsedDate spotlight metadata attribute.

j o a r


On 7 jul 2011, at 20:35, Rick C. wrote:

> Hi again,
>
> I'm using this code to get the last accessed date of a file:
>
> struct stat output;
>
>    int ret = stat([aFile fileSystemRepresentation], &output);
>    struct timespec accessTime = output.st_atimespec;
>   NSDate *aDate = [NSDate dateWithTimeIntervalSince1970:accessTime.tv_sec];
>
>    NSLog(@"Access Time %d, %@",ret, aDate);
>
> But it's just giving me today's date.  There must be something obvious I'm doing wrong but I have not been able to figure it out.  Any pointers?  And I couldn't use NSURLContentAccessDate because I still need 10.5 support.  Thanks!
>
> rc_______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: getting last accessed date
      • From: "Rick C." <email@hidden>
References: 
 >getting last accessed date (From: "Rick C." <email@hidden>)

  • Prev by Date: Re: getting last accessed date
  • Next by Date: Re: getting last accessed date
  • Previous by thread: Re: getting last accessed date
  • Next by thread: Re: getting last accessed date
  • Index(es):
    • Date
    • Thread