Results 1 to 6 of 6

Thread: date modified [Resolved]

  1. #1

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    date modified [Resolved]

    I'm trying to put the date a file was modified on each page that I have but I want to put that in an included file (footer.php) and I'm using the following code:
    PHP Code:
    $modified stat(); 
    echo 
    " " date("l, F dS",$modified[9]); 
    Where the name of the file you're getting the stats on is the name of the current page you're on.

    The problem is, all server variables that are available also contain the path to that file. How do I remove the folder/path name from the $_SERVER['SCRIPT_NAME'] call?

    Or is there a better way to do this?
    Last edited by ober0330; Apr 7th, 2004 at 09:06 AM.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  2. #2

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Got it:
    PHP Code:
    $tok strtok($_SERVER['SCRIPT_NAME'], "/");
    $sname "";
    while (
    $tok) {
        if(
    trim($tok) != "")
            
    $sname $tok;
        
    $tok strtok("/");
    }
    $modified stat($sname); 
    echo 
    "<br>Procedure Modified: " date("n/j/Y",$modified[9]); 
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  3. #3
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    Found this have a look

    PHP Code:
    <?php
    // outputs e.g.  somefile.txt was last modified: December 29 2002 22:16:23.

    $filename 'somefile.txt';
    if (
    file_exists($filename)) {
       echo 
    "$filename was last modified: " date ("F d Y H:i:s."filemtime($filename));
    }
    ?>
    http://uk.php.net/manual/en/function.filemtime.php

  4. #4

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Thanks

    New code:
    PHP Code:
    $tok strtok($_SERVER['SCRIPT_NAME'], "/");
    while (
    $tok) {
        if(
    trim($tok) != "")
            
    $sname $tok;
        
    $tok strtok("/");
    }
    echo 
    "<br>Procedure Modified: " date("n/j/Y",filemtime($sname)); 
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  5. #5
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Why loop when you don't have to?

    PHP Code:
    $sname substr($_SERVER['SCRIPT_NAME'], strrpos($_SERVER['SCRIPT_NAME'], '/') + 1);

    echo 
    "<br>Procedure Modified: " date("n/j/Y",filemtime($sname)); 
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    ah ha... see... that's the solution I was looking for

    Thanks
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

Posting Permissions

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



Click Here to Expand Forum to Full Width