php displaying last modification time

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

    php displaying last modification time

    Hello,
    Trying to get a php script to display when a web page was last modified.
    My code is below, i'm getting a last modified date of dec. 31 1969 which is
    wrong for one, and does not change if i modify the resulting file. The code
    itself is in an include file, a footer file, which will be included at the
    bottom of every page. Suggestions?
    Thanks.
    Dave.

    <?

    echo "This file was last modified: ";

    $temp = pathinfo($PHP_S ELF);

    echo strftime("%A %B %d, %Y", filemtime($temp["basename"]));

    ?>


  • Till Glöggler

    #2
    Re: php displaying last modification time

    dave wrote:[color=blue]
    > Hello,
    > Trying to get a php script to display when a web page was last modified.[/color]
    [...][color=blue]
    >
    > <?
    >
    > echo "This file was last modified: ";
    >
    > $temp = pathinfo($PHP_S ELF);[/color]

    Maybe the error is here. Do you have register_global s = on?
    If not, this should work for you:
    $temp = pathinfo($SERVE R['PHP_SELF']);
    [color=blue]
    >
    > echo strftime("%A %B %d, %Y", filemtime($temp["basename"]));
    >
    > ?>[/color]

    HTH,

    Till

    Comment

    • Agelmar

      #3
      Re: php displaying last modification time

      Till Glöggler wrote:[color=blue]
      > dave wrote:[color=green]
      >> Hello,
      >> Trying to get a php script to display when a web page was last
      >> modified. [...]
      >>
      >> <?
      >>
      >> echo "This file was last modified: ";
      >>
      >> $temp = pathinfo($PHP_S ELF);[/color]
      >
      > Maybe the error is here. Do you have register_global s = on?
      > If not, this should work for you:
      > $temp = pathinfo($SERVE R['PHP_SELF']);[/color]

      this should be $_SERVER['PHP_SELF'] (note the underscore before SERVER)


      Comment

      • dave

        #4
        solved Re: php displaying last modification time

        Hello,
        My thanks to everyone who helped with my last modification time issue.
        In summary i did not have register_global s on and the code now is:

        <?

        echo "This file was last modified: ";

        $temp = pathinfo($_SERV ER['PHP_SELF']);

        echo strftime("%A %B %d, %Y", filemtime($temp["basename"]));

        ?>



        Hope this helps someone and again thanks for the assist.

        Dave.




        Comment

        • Chung Leong

          #5
          Re: php displaying last modification time

          Use $_SERVER['SCRIPT_FILENAM E'] instead. PHP_SELF is the URI of the running
          script. Your script would fail if some of letters in URI are in the wrong
          case.

          Uzytkownik "dave" <dmehler26@woh. rr.com> napisal w wiadomosci
          news:iPrLb.2838 $RT.1226@fe2.co lumbus.rr.com.. .[color=blue]
          > Hello,
          > Trying to get a php script to display when a web page was last[/color]
          modified.[color=blue]
          > My code is below, i'm getting a last modified date of dec. 31 1969 which[/color]
          is[color=blue]
          > wrong for one, and does not change if i modify the resulting file. The[/color]
          code[color=blue]
          > itself is in an include file, a footer file, which will be included at the
          > bottom of every page. Suggestions?
          > Thanks.
          > Dave.
          >
          > <?
          >
          > echo "This file was last modified: ";
          >
          > $temp = pathinfo($PHP_S ELF);
          >
          > echo strftime("%A %B %d, %Y", filemtime($temp["basename"]));
          >
          > ?>
          >
          >[/color]


          Comment

          Working...