Problem with filemtime- am I missing something?

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

    Problem with filemtime- am I missing something?

    I am a newb I have to admit at this programming lark (i have tried various
    languages in the past but can't seem to find my way round them, but for once
    I feel I am getting somewhere with php and have written my first functional
    program that does something useful (well for me anyway!).

    The purpose of the program is to read some logfiles we import to our
    webserver and parse out some lines which are displayed on a website (near
    real time stats essentially)
    All this works fine but one part of my output does not read as I would
    expect.
    When my script reads each logfile it also picks up the date and time of the
    last modified time of the file. As these logs are replaced every 10 minutes
    its important I can see when the latest stats are essentially. I use the
    filemtime() function.
    The basic funtionality seems to work but the time I get out is odd. I have
    broken my code down to a simple read the file time and print it on screen
    but this returns the same time.
    If I telnet to the server and read the last modded time it says (at present
    10:22) But my php script outputs 10:02. This seems to stay like this for an
    hour then outputs 11:02.
    Its like it only sees hourly changes (always at 2 mins past the hour) I
    thought it might be some sort of cacheing so have called clearstatcache( ) in
    my script but this makes no difference. What time is this showing me here
    then if its not the true system file modification time? any ideas?


  • Ken Robinson

    #2
    Re: Problem with filemtime- am I missing something?


    Kenny Halley wrote (in part):

    [snip]
    [color=blue]
    > If I telnet to the server and read the last modded time it says (at[/color]
    present[color=blue]
    > 10:22) But my php script outputs 10:02. This seems to stay like this[/color]
    for an[color=blue]
    > hour then outputs 11:02.
    > Its like it only sees hourly changes (always at 2 mins past the hour)[/color]
    I[color=blue]
    > thought it might be some sort of cacheing so have called[/color]
    clearstatcache( ) in[color=blue]
    > my script but this makes no difference. What time is this showing me[/color]
    here[color=blue]
    > then if its not the true system file modification time? any ideas?[/color]

    May we see your code? It's pretty hard to tell what might be wrong
    without the code.

    Ken

    Comment

    • Senator Jay Billington Bulworth

      #3
      Re: Problem with filemtime- am I missing something?

      "Kenny Halley" <kenny@halleyne t.com> wrote in
      news:cugje5$r7t $1$8302bc10@new s.demon.co.uk:
      [color=blue]
      > The basic funtionality seems to work but the time I get out is odd. I
      > have broken my code down to a simple read the file time and print it
      > on screen but this returns the same time.
      > If I telnet to the server and read the last modded time it says (at
      > present 10:22) But my php script outputs 10:02. This seems to stay
      > like this for an hour then outputs 11:02.[/color]

      You keep getting 02 because it's February.

      OK, I was tempted to stop there and give your brain a workout ;) but I
      guess I'll toss in the explanation. When using date functions, 'm'
      represents the month in numeric form, not the minute. You want to use
      'i' to get the minute, e.g.

      echo date('Y-m-d H:i');

      hth


      --
      Bulworth : PHP/MySQL/Unix | Email : str_rot13('f@fu ng.arg');
      --------------------------|---------------------------------
      <http://www.phplabs.com/> | PHP scripts, webmaster resources

      Comment

      • phpcode

        #4
        Re: Problem with filemtime- am I missing something?

        Use clearstatcache before calling filemtime.

        Comment

        Working...