SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question why does getlastmod() return false?

    I have this line of php code in a simple php file:

    echo(" Last modified on " . date( "F j, Y", getlastmod()) );

    The output is December 31, 1969, because the getlastmode() function returns false. Why and how do I fix it?

  2. #2
    Probably eating pie mitsubishi's Avatar
    Join Date
    Sep 2001
    Location
    England, UK
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dunno why it doesn't work, try this:

    PHP Code:
    echo(" Last modified on " date"F j, Y"filemtime(addslashes($_SERVER['PATH_TRANSLATED']))) ); 
    Both work for me.

  3. #3
    SitePoint Member
    Join Date
    Jul 2002
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried your suggestion:
    PHP Code:
    echo(" Last modified on " date"F j, Y"filemtime(addslashes($_SERVER['PATH_TRANSLATED']))) ); 
    and it give me an error message.

    But then I tried filemtime("filename") inside the date function and it worked!
    Thanks for suggesting filemtime()!!

  4. #4
    Probably eating pie mitsubishi's Avatar
    Join Date
    Sep 2001
    Location
    England, UK
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Funny you got an error, but I'm glad you got it working. The only error I could think possible would be if your PHP is <4.1.0 and $_SERVER wouldn't be available, but if getlastmod() doesn't work then maybe it's a little mad anyway


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
  •