Click to See Complete Forum and Search --> : Bug in getlastmod() (?)


mf22cs
06-10-2003, 09:04 PM
Hi,

I wonder... is there a bug in the function getlastmod() or not?

The CVS-people at php.net say that it is not, and users all over say that there is a bug.

I run:
PHP 4.3.1
Apache 1.3.27
Linux/Slackware 2.4.18

And when I use getlastmod() i get the last access time of the file, not the mod-time.

Why? Any workaround?

Is the bug in PHP, Apache... or what?

/marcus

pyro
06-10-2003, 09:45 PM
Try filemtime()... that's what I use. http://us2.php.net/manual/en/function.filemtime.php

jrthor2
06-11-2003, 07:55 AM
I use this and have no problems. It displays the last time the file was modified:

<?echo Date("F d, Y h:i T", getLastMod());?>

mf22cs
06-11-2003, 01:56 PM
Well, it seems to work sometimes and not sometimes.

At bugs.php.net there at more like me, having problems... it is an known bug, but where the bug is not knowen...

At php.net they say itīs the Apache-server. And there aer those who say itīs in the PHP.

/Marcus

PS!
I used this thing that Pyro posted, and that works great...
DS!

mf22cs
06-16-2003, 04:43 PM
Originally posted by pyro
Try filemtime()... that's what I use. http://us2.php.net/manual/en/function.filemtime.php

This works great, but I installed php on my localhost today. And when I tried with "filemtime" I got the result:

Wed, 1 Jan 1970

Well, on the real webserver "filemtime" results in the correct date, but not on my localhost.

Strange!?!

My webserver is running: Linux/Slack 2.4.18, Apache 1.3.27 with PHP 4.3.1

On my localhost I run: WinXP Pro, IIS 5.1, PHP 4.3.2

/Marcus

mf22cs
06-16-2003, 04:45 PM
BTW: getlastmod() works on localhost

But works less good on the webserver... as I wrote before...

/Marcus

pyro
06-16-2003, 04:52 PM
Just checked filemtime()... worked fine for me on my local server (Win XP Home, Abyss, PHP 4.3.1) and my remote server (same specs as yours)...

mf22cs
06-16-2003, 05:06 PM
Any suggestions? Where do I find the solution to this odd "error"?

php.ini?
extensions?

/Marcus

pyro
06-16-2003, 05:11 PM
To be honest, I'm not sure. I don't know all that much about server administration... Sorry.

diamonds
06-16-2003, 05:17 PM
wensday,the first of January,1970 is.. somthing of importance. I think it is the time apache bases off of, also one command in javascript returns the number on milaseconds there has been as of that date! Oh, yes! Thats where I saw it from!

pyro
06-16-2003, 05:20 PM
Yes, it is. It is the Unix epoch... (January 1 1970 00:00:00 GMT)

mf22cs
06-16-2003, 05:31 PM
Well, Diamond, thanks for telling us all that... but that does not help me.

This is my code:


function datum($what){
$manader = array("januari","februari","mars","april","maj","juni","juli","augusti","september","oktober","november","december");
if ($what=="mod") {
// OPTION 1 OR OPTION 2
} else if ($what=="now") {
$dag = date("j");
$manad = $manader[date("n")-1];
$aar = date("Y");
}
echo $dag ." ". $manad ." ". $aar;
}


Option 1 (that works fine on my localhos):

$dag = date("j", getlastmod());
$manad = $manader[date("n", getlastmod())-1];
$aar = date("Y", getlastmod());



Option 2 (well... works fine on my webserver):

$dag = date("j", filemtime($_SERVER["SCRIPT_FILENAME"]));
$manad = $manader[date("n", filemtime($_SERVER["SCRIPT_FILENAME"]))-1];
$aar = date("Y", filemtime($_SERVER["SCRIPT_FILENAME"]));


/Marcus

mf22cs
06-16-2003, 06:20 PM
To get it more readable I made this test.php-file to show you what I talk about...


GLM: <?php
echo date("d-m-Y H:i:s",getlastmod());
?>
<br/>FMT:<?php
echo date("d-m-Y H:i:s",filemtime($_SERVER["SCRIPT_FILENAME"]));
?>


At the server this gives the following result:
GLM: 17-06-2003 01:11:35
FMT:17-06-2003 01:18:23

And at local host:
GLM: 17-06-2003 01:18:21
FMT:01-01-1970 01:00:00

Solutions?

/Marcus