PHP Diary | PHP Housekeeping | PHP Scripts | TD Scripts.com
[back]
12/21/99 "Adding date/time last updated"
[next]
Here is a tutorial online for PHP that is really good from DevShed:
tutorial
http://www.devshed.com/Server_Side/PHP/Introduction/page1.html
...more PHP resource sites I've visited
We went through date function and now let's look at filemtime really quick. It is our first visit to a file function. I want to add a link next to my copyright notice on each diary page which will tell people the last date and time the page was updated. Obviously the date I originally write my notes will be the date above, but in future lessons we may add things to these pages and I want to be able to refer back to them and for you to see when changes were last made.
<?
$last_modified = filemtime("example7.php3");
print("Last Modified ");
print(date("m/j/y h:i", $last_modified));
?>
example #7 page "Last Modified month/day/date hour:minute" format <--- this will show the last time the example7.php3 file was modified. To see the last time this diary page was located click here.
You might be wondering what the date function was used for. The filemtime function returns time in timestamp format and thus needs to be formatted by the date function in order to be in a useful format. See 121799 diary page or the php manual for a list of date codes. Any time you want to modify the timestamp use the date function on the left and the variable to be modified on the right enclosed in parenthesis.
Using Front Page 2000 (or 98) with PHP
The <? and ?> tags don't work very well with the Front Page and other some other editors out there. Fortunately you can use the script tag instead. Like this:
<script
language="php">
insert PHP code here
</script>
My suggestion is to get used to using a good text editor for any of your scripting needs. Microsoft Wordpad works good, but there are others. Programmers coming from the C or C++ environment probably already have the own they are comfortable with, Unix people have vi.
[back]
12/21/99 "Adding date/time last updated"
[next]
PHP Diary | PHP Housekeeping | PHP Scripts | TD Scripts.com
Copyright 2000 php-scripts.com Last Modified 02/9/04 11:27