need PHP to read file date in directory

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JackM

    need PHP to read file date in directory

    Is there a way to use PHP to read the date of a file that is uploaded
    into a directory and then print out that date on another page?

    I'm looking to have a specific file (/texts/filename.pdf) located in the
    directory and the date of its last change/modification printed into a
    date("F, n, Y"); format on another page. I checked the PHP manual but
    couldn't find any date/time functions that were what I needed.
  • NC

    #2
    Re: need PHP to read file date in directory

    JackM wrote:
    >
    Is there a way to use PHP to read the date of a file that is uploaded
    into a directory and then print out that date on another page?
    Yes:

    echo date('F, n, Y', filemtime('/texts/filename.pdf')) ;
    I checked the PHP manual but couldn't find any date/time functions
    that were what I needed.
    Check again:





    Cheers,
    NC

    Comment

    • JackM

      #3
      Re: need PHP to read file date in directory

      NC wrote:
      >>Is there a way to use PHP to read the date of a file that is uploaded
      >>into a directory and then print out that date on another page?
      >
      Yes:
      >
      echo date('F, n, Y', filemtime('/texts/filename.pdf')) ;
      Everything is coming up with a December 12, 1969 date when I use this.
      Any idea why?

      Comment

      • JackM

        #4
        Re: need PHP to read file date in directory

        JackM wrote:
        NC wrote:
        >
        >>Is there a way to use PHP to read the date of a file that is uploaded
        >>into a directory and then print out that date on another page?
        >>
        >>
        >Yes:
        >>
        >echo date('F, n, Y', filemtime('/texts/filename.pdf')) ;
        >
        >
        Everything is coming up with a December 12, 1969 date when I use this.
        Any idea why?
        Found out why. I had to go up one more level to read the file:
        filemtime('./texts/filename.pdf')

        But the strange thing is that the file dates are all coming out January
        1, 2007 now even when the files were created and/or modified after that
        date.

        --
        My email address on the header is a non-monitored spam catching account.
        I can be reached via http://www.wvnh.net/contact.htm

        The dates for the next RADP meet (RADP-XII) are October 12-15, 2007,
        followed by the 2007 Holiday Meets on December 7-10, 2007.

        Comment

        • no@email.com

          #5
          Re: need PHP to read file date in directory

          But the strange thing is that the file dates are all coming out January
          1, 2007 now even when the files were created and/or modified after that
          date.
          >
          try adding clearstatcache( ) function before the filemtime()

          clearstatcache( );
          filemtime('./texts/filename.pdf');

          Comment

          • JackM

            #6
            Re: need PHP to read file date in directory

            no@email.com wrote:
            >>But the strange thing is that the file dates are all coming out January
            >>1, 2007 now even when the files were created and/or modified after that
            >>date.
            >>
            >
            >
            try adding clearstatcache( ) function before the filemtime()
            >
            clearstatcache( );
            filemtime('./texts/filename.pdf');
            Thanks for the suggestion but it didn't change anything.

            Comment

            Working...