question about some javascript code

dharmil

New Member
Messages
1,656
Reaction score
0
Points
0
i use this code to write when i last modified a document
Code:
<script> document.write(document.lastModified);</script>
but this just displays the curent time/date to the seconds
 

Torch

New Member
Messages
634
Reaction score
0
Points
0
That is because javascript reads when the document was last modified on clients side, eg. when it was loaded, eg. the current time. It can't display info about a file on server side.

To display last modified time of a file, use something like this (PHP):
PHP:
<?
printf("This file was last modified on %s.",date("Y. m. d. H:i",filemtime(basename($_SERVER["PHP_SELF"]))));
?>

Only things that you might want/need to change are basename($_SERVER["PHP_SELF"]) to path to your file in case you don't want to show last modified time of file currently accessed, and date formatting.
 
Last edited:
Top