timestamp

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vietboy505
Forum Commoner
Posts: 53
Joined: Wed Feb 22, 2006 9:30 am

timestamp

Post by vietboy505 »

This script show the time of the file last modify. So every PHP I write, I have to replace file.php to something else.
Is there possible way of not doing of not doing this?

Code: Select all

<br><br>
<?php
$last_modified = filemtime("file.php");
print("Last Modified: ");
print(date("M-j-Y h:i:s", $last_modified));
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<?php

function lastModified()
{
  list($data) = debug_backtrace();
  $out = '';
  if (isset($data['file']))
  {
    $out .= 'Last Modified: ' . date('Y-m-d H:i:s', filemtime($data['file']));
  }
  return $out;
}

?>
maybe
vietboy505
Forum Commoner
Posts: 53
Joined: Wed Feb 22, 2006 9:30 am

Post by vietboy505 »

that work!

thx
Post Reply