date

last change: 2010-05-28, 08:46

The last time a page was changed can be shown by some javascript. That does not work on PHP files:

Last change:

At the moment the page is opened HTML is generated. You do get the correct date for that HTML code but you want the date of the underlying PHP file. You need a bit of PHP to do that:

	<b class=wijz>
	<?php  
	date_default_timezone_set("CET"); 
	echo "last change: " . date ("Y-m-d, H:i", filemtime("date.php"));
	?>
	</b>

There is a problem with Safari, Chrome, Opera, Javascript and lastModified. It does not work, no known solution. Internet Explorer and Firefox have no problems with this Javascript:

	var dt = new Date(document.lastModified);
	if(isNaN(dt))document.write("???");
	else{
		var m = dt.getMonth() + 1;
		if(m<10) m = "0"+m;
		var d = dt.getDate();
		if(d<10) d = "0"+d;
		var h = dt.getHours();
		if(h<10) h = "0"+h;
		var mi = dt.getMinutes();
		if(mi<10) mi = "0"+mi;
		document.write(" " + dt.getFullYear() +"-"+m+"-"+d+", "+h+":"+mi);
	}

Another problem: some hosting computers do not supply lastModified, Javascript can't find it. PHP runs on the hosting computer, filemtime always works. Better modify your *.hmtl into *.php

Nederlands


datum

English

home start lunascape php and include date code ubuntu menu, alternative statistics php and photos guestbook webshop javascript dirlist infrared calendar search contact