0

How would I increase update time, or make updates automatic in PHP?

This is currently the code I have:

<center>Last Updated on '.date("F j, Y, g:i a",time()+3600).'</center><br>

The issue here is that I have, the file updating every couple hours. That being said, I cannot automatically see the changes I make to the PHP on the site, only locally.

jjf3
  • 27
  • 1
  • 7
  • `time()` gets the current time. All you're doing is printing out the current time when the user loads the page, +1 hour. How is it related to anything being updated, or what would you like the time to be based on, if not the current time of viewing the page? – BadHorsie Oct 23 '13 at 13:08
  • @badHorsie: I have this updating every couple hours automatically, maybe it's a different script, but I have no idea. I would like to change the intervals of the updates, but that is the only piece of code I see that is related to date/time. – jjf3 Oct 23 '13 at 13:13
  • Like I say, the code you have posted is simply printing out the current time. If you did not write the code yourself, I would guess that the developer who did is just using this as a "fake" update timestamp. All they are doing is showing the current time to the user. Either that or you have the wrong line of code. If you are trying to find the correct piece of code, might I suggest you search for whatever the page says (e.g. "Last Updated") not search for the word "date/time" as this may not be used at all if the update time is based on a stored variable somewhere. – BadHorsie Oct 23 '13 at 13:24
  • @BadHorsie, what should I be looking for if I was trying to find the file that does update this? You are probably right about the timestamp, but nothing at all in my site's FTP files indicates a way to increase/decrease the updating time. I assume it would be a PHP script. Right now, I am updating the logo and header of this particular file. – jjf3 Oct 23 '13 at 13:35
  • I did find this: set_time_limit(0); but this seems to just run the updates constantly...Nothing specific about a couple of hours. – jjf3 Oct 23 '13 at 13:44
  • Okay, from the way you are talking about FTP, when you say you can't see the the changes "on the site" what exactly do you mean? I think we are confused about what you are asking and it's possibly not a PHP coding question. Are you talking about the "last updated" times changing in Filezilla, or does your website itself display a message to the visitors which says "Last updated on ..."? And when you say "I have this updating every couple hours automatically" what is updating? Can you explain these things very literally and I will hopefully figure out what you're after. – BadHorsie Oct 23 '13 at 14:57
  • I don't know exactly. I have a txt file called inventory.txt. I use parse4.php to make changes, create, and update a page called iventory4.html. If I edit the html only, I see the changes instantly, but I don't get to keep them, because parse4.php overwrites it every two hours. I would like to be able to see the updates instantly and keep the updates coming with same settings. EX: updating every two hours. – jjf3 Oct 23 '13 at 17:01

1 Answers1

0

If you're trying to get the last modified time of a file use filemtime()

int filemtime ( string $filename )
This function returns the time when the data blocks of a file were being written to, that is, the time when the content of the file was changed.

<?php
// outputs e.g.  somefile.txt was last modified: December 29 2002 22:16:23.

$filename = 'somefile.txt';
if (file_exists($filename)) {
    echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
}
?>
John Conde
  • 217,595
  • 99
  • 455
  • 496
  • Thanks but i can also find that out in Filezilla which is my FTP program. I'm just wondering what type of php code could update the file. Maybe it's something I'm missing. I do have this: set_time_limit(0); – jjf3 Oct 23 '13 at 13:53