What PHP code to display a "Last Modified" date is best?

Vince

New member
I want a "Last Updated: ....." display on my article pages, and in my searches I've come across two scripts.

Code A
-----------------------
<?php echo date( "F d, Y", getlastmod() );?>

Basically, "Set it and forget it." All I have to do is insert this code, and it'll update whenever I make a modification (aka re-upload) the page. However, some people have said that this code isn't as "good" as this one...

Code B
-----------------------
<?php
$last_modified = filemtime("Untitled.php");
print("Published: ");
print(date("m/j/y", $last_modified));
?>

This code is supposed to be "better" than Code A, however if I were to use this code then I'd have to manually insert the page(file) name [see "Untitled.php"] in each and every page.

So for all the PHP code wizards out there...is there really any issues with using either code? Is A less reliable or unstable than B? I'd prefer to use Code A, but now I'm wary because of this supposed inferiority to B.
 
Back
Top