473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem with filemtime- am I missing something?

I am a newb I have to admit at this programming lark (i have tried various
languages in the past but can't seem to find my way round them, but for once
I feel I am getting somewhere with php and have written my first functional
program that does something useful (well for me anyway!).

The purpose of the program is to read some logfiles we import to our
webserver and parse out some lines which are displayed on a website (near
real time stats essentially)
All this works fine but one part of my output does not read as I would
expect.
When my script reads each logfile it also picks up the date and time of the
last modified time of the file. As these logs are replaced every 10 minutes
its important I can see when the latest stats are essentially. I use the
filemtime() function.
The basic funtionality seems to work but the time I get out is odd. I have
broken my code down to a simple read the file time and print it on screen
but this returns the same time.
If I telnet to the server and read the last modded time it says (at present
10:22) But my php script outputs 10:02. This seems to stay like this for an
hour then outputs 11:02.
Its like it only sees hourly changes (always at 2 mins past the hour) I
thought it might be some sort of cacheing so have called clearstatcache() in
my script but this makes no difference. What time is this showing me here
then if its not the true system file modification time? any ideas?
Jul 17 '05 #1
3 2828

Kenny Halley wrote (in part):

[snip]
If I telnet to the server and read the last modded time it says (at present 10:22) But my php script outputs 10:02. This seems to stay like this for an hour then outputs 11:02.
Its like it only sees hourly changes (always at 2 mins past the hour) I thought it might be some sort of cacheing so have called clearstatcache() in my script but this makes no difference. What time is this showing me here then if its not the true system file modification time? any ideas?


May we see your code? It's pretty hard to tell what might be wrong
without the code.

Ken

Jul 17 '05 #2
"Kenny Halley" <ke***@halleynet.com> wrote in
news:cu*******************@news.demon.co.uk:
The basic funtionality seems to work but the time I get out is odd. I
have broken my code down to a simple read the file time and print it
on screen but this returns the same time.
If I telnet to the server and read the last modded time it says (at
present 10:22) But my php script outputs 10:02. This seems to stay
like this for an hour then outputs 11:02.


You keep getting 02 because it's February.

OK, I was tempted to stop there and give your brain a workout ;) but I
guess I'll toss in the explanation. When using date functions, 'm'
represents the month in numeric form, not the minute. You want to use
'i' to get the minute, e.g.

echo date('Y-m-d H:i');

hth
--
Bulworth : PHP/MySQL/Unix | Email : str_rot13('f@fung.arg');
--------------------------|---------------------------------
<http://www.phplabs.com/> | PHP scripts, webmaster resources
Jul 17 '05 #3
Use clearstatcache before calling filemtime.

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Erica | last post by:
Hey, I need a function to obtain the "last modified" timestamp from a file. filemtime works perfectly well when I am working with a file on my server. However, sometimes I need to pass it a full...
0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
117
by: Peter Olcott | last post by:
www.halting-problem.com
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
3
by: imrantbd | last post by:
Hi this is Imran, I am facing some problem to track file upload time in a linux hosting. I used filectime / filemtime to track date. But I get the time stamp of locally file creation time.I can...
1
by: yawnmoth | last post by:
Say I have the following script: <?php $timestamp = filemtime("test.txt"); echo 'original file time<br />'.$timestamp.'<br />'; $fp = fopen("test.txt",'w'); fputs($fp,$data); fclose($fp);
5
by: yhd1997 | last post by:
Can you please help me to solve this cache problem? I have a php script that can save the content to a cache folder. But I can not get it to work to display the cached page. The script will...
2
by: Jeff | last post by:
I see that php has filemtime and stat. I don't see how to set a files last modification time. How do you do that? Jeff
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.