SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to check if file is more than 10 minutes old?

    Basically, I just need to know if a certain file is more than XX minutes old.

    Is there an "easy" way to do this?

  2. #2
    SitePoint Zealot
    Join Date
    Oct 2001
    Location
    London, UK.
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have a look into:

    http://www.php.net/fileatime
    or
    http://www.php.net/filectime
    or
    http://www.php.net/filemtime

    They might do what you're looking for.

    David
    Do you fear the obselescence of the
    metanarrative apparatus of legitimation?

  3. #3
    SitePoint Wizard Mincer's Avatar
    Join Date
    Mar 2001
    Location
    London | UK
    Posts
    1,140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like this would tell you when the file was last changed, you can change it to suit your needs.

    PHP Code:
    $file 'somefile.xyz' ;
    $time 600 //seconds

    if( ! file_exists$file ) )
    {
      echo 
    'file does not exist' ;
    }
    else
    {
      if( 
    time() - filemtime$file ) <= $time )
      {
        echo 
    'file last changed under 10 mins ago' ;
      }
      else
      {
        echo 
    'file last changed more than 10 mins ago' ;
      }

    Matt.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •