Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Displaying Modified Date Of A URL File


I want to display a web page with links to various documents and display the date each document was last modified next to the link. I've found the filemtime command and that works quite nicely for "local" files. However, filemtime doesn't work if the file(s) are refered to by their URLs (which is how I need to do it).

A comment on the manual page (http://www.php.net/manual/function.filemtime.php3) refers to having to use "Socket Operations" but the link posted with that comment doesn't work (it just goes to a page saying the website has been rearranged).




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Modified Date For Alternative File
Is there a way to add the last modified date for an alternative file into another one? My problem is that when I use getlastmod it is looking at the date on a file that controls headers/background etc for the page, but not the file that is accessed during modification of the data. Is there any way to add a line of code to get the modified date from the data file?

Last Modified Date
Is there any way to access the last modified date of a page off your own domain?

Show Last Modified Date From DB In PHP
Is there a way to show in PHP automatic the date when a DB was last
modified?

Change Modified Date Automatically
on my website my index page is php, and I update some of the content on a daily basis, I use a news script, but this does not update the pages actual "Date Modified"

I want to be able to have this as always changing as my content is too, I dont want search engine spiders thinking that I do not update my content..

so rather than manually opening my pages then re-saving them is there any way to automatically do this?

Deleting Files In A Folder Modified Before Certain Date
I use a cache system that requires creation of files in a folder .

Now , what i need to know is how can i delete files created say 3 days ago.

So that the cache remains fresh.

The directory contains around 20,000 files , about 10,000 are generated each day (if they dont exist)

So getting info about the each file after using opendir will cause the server to slow down.

Help With Displaying Selecting A Date Range And Displaying Results
I wish to create a simple form that allows the selection of a start date and a stop date with the ability to select what columns to be displayed in the result page.

Get The TIME A File Was Modified ??
1st step - I can get the "current time" -


$tr=time();
echo "TIME = $tr<BR>";
RESULT "TIME = 1135860780"


OK...

I CAN get the last time a file was last modified :-

echo "FILe - '$file'<BR>";
if (file_exists($file)) {
$ta=date ("F d Y H:i:s.", filemtime($file));
echo "The file was last modified: $ta<BR>";
}

RESULT = "The file was last modified: July 30 2005 03:05:20."

However - My problem....

i am having a problem - Converting the time shown above - into a UNIX
timestamp...

$taw = date('d/m/Y H:i:s', $ta) ;
echo "Time Modified = '$taw'<BR>";
$taw=strtotime('$ta');
echo "Time Modified = '$taw'<BR>";
$taw=strtotime($ta);
echo "Time Modified = '$taw'<BR>";

But the result I get is :-

Displaying Date
i'm working on K Yank's book and, at some point, i've an insert like this:

$sql = "INSERT INTO Jokes SET
...
JokeDate = CURDATE()";

When i dysplay this on my webpage, the date format is YYYY,MM,DD
and in my country (Portugal), the format is day, month, year
How can i achieve it?

Displaying Date...
As a final touch to my current project I am trying to display a "Last Updated: " field on the user profile pages of the website. The SQL database is updating the field last_updated automatically any time a record is altered, and this is working fine...

Structure details from phpMyAdmin (in table 'users'): last_updated timestamp  ON UPDATE CURRENT_TIMESTAMP No 0000-00-00 00:00:00

However when I try to output this date I get the result:

Profile Updated: January 1, 1970

The code I am using is as follows... Code:

Displaying A Date
My current code:

foreach ($page['events'] as $z) {

echo '<b>', $z['date'],  '</b></p>';

}

Which is pulling "date" from a DATE field in the database. Would like it to display as 3-22-2007 ... instead of 2007-3-22 - I know theres a quick answer out there but cant find it.

Displaying A Date Range
I would like to display a user specified date range e.g Monday to Monday next week or maybe Monday next month. When I have the basic function worked out I would like to get Data from a Mysql Database. here is what I have thought about. Code:

Displaying A Date With Strtotime
I have successfully used strtotime to format the date on a webpage that is
pulled form a MySQL database in the form yyyy-mm-dd.

However, in another part of the webpage, I have to insert another date that
may contain a NULL entry in the database. If I use strtotime to format this
then it enters the current date, whereas I want it left blank.

Displaying Date From A Database
All I need to do is change the date so it reads, for example, May 1999 when it's displayed on the page. Code:

Displaying The Date In A Different Format!
I have a row called Date in the databse which is saved as 0000-00-00 When I try to echo it, it shows like that 2007-04-16 Maybe because I use this normal code: echo $row['Date']; How can I display it like that:16-04-2007

Displaying Date/time
I'm trying to display a datetime type which I save with NOW()

ie:
    // create query
    $query = "INSERT INTO purchase (category, location, price, time) VALUES ('$category', '$location', '$price', NOW())";
time is a datetime type

I want to just display the "time" part of time,  not the date

this is the code I'm using:
echo "<li><a href=".$_SERVER['PHP_SELF']."?category=".$row[5].">".date("G.i:s", $row[5]."</li>";
and getting a "Parse error: syntax error, unexpected ';' ..."

Date/time Displaying Wrong
How do I set the time display to echo the time, in the timezone the user is in and not the server time. For somereason im in eastern timezone and the host server i9s in central and the time displayed on my laptop is in central.

Displaying 'new' Icon Based On Date?
I'd like to display a little "new" icon next to all products in a directory which are, funnily enough, new! I've got a date (timestamp) for each product which is inserted on adding a new product and updating a product.

I'd like to do a conditional region using the timestamo but I'm not sure what to use - I could do === [current date] but that would only show the icon for that day and I'd like it to be there for about a week or so.

Reading And Displaying A Date From A MySql Database
I've just started using php, and although I am very impressed by it,
there are some things with which I am confounded!

What I'm trying to do is read in a Date from a mySql database and then
display it on screen (the Date is in the usual yyyy-mm-dd format).

If I use SQL on phpadmin
SELECT Date
FROM details
WHERE details.Name = "Paul Lee"
LIMIT 0 , 30

The result comes up 2005-01-01, so this seems to work.
But if I use the following:

$db = mysqli_connect("localhost","root","");
@mysqli_select_db($db, "personnel") or die ( "Unable to select
database" );
$query = 'SELECT Date FROM details WHERE details.Name = "Paul Lee"
LIMIT 0, 30'

$result=mysqli_query($db, $query);

echo "<br>";

echo $result;

mysqli_close($db);

I get "Object id #2" displayed on screen.
I have tried to use the explode function to separate the months, year
and day using the "-" as a delimeter, but this doesn't work, and I
can't seem to get the other php date/time functions to work either.

Displaying Local Date In Specific Format
i'm trying to decide whether to use PHP or JavaScript to display a date on a website. what i'm wondering is where does PHP take the date from, the server or the client (ie will timezone become a factor). aswell as this, is there a simple way to allow the date to be displayed as: "22nd" "1st" or "14th" instead of "22" "1" or "14"?

Displaying File Path In File Input Field
i have file input field in a form like this:
<input name="isbn" type="text" size="25" value="<?php echo
$_POST['isbn'] ?>" />
<input name="image" type="file" size="25" value="<?php echo
$_FILES['image']['name'] ?>" />

when i press "submit" button, the same page gets loaded... if my
$_POST['isbn'] is empty, i want to have the file path on "file input
field" to redisplay on that same field... it's possible in text input
field but i don't know of a way to do it in file input fields...

Using Last-Modified
I want to use Last-Modified in a php script, but
it doesn't seem to work somehow.

i use the following code where $FileDate is a formated date like:
Sun, 06 Nov 1994 08:49:37 GMT (RFC 822, updated by RFC 1123)

if($HTTP_IF_MODIFIED_SINCE==$FileDate)
{
header("Status: 404 Not Modified");
die();
}

header("Last-modified: ".$FileDate);
header("Content-type: ".$FileType);
print $FileData;

somehow the server doesn't send the header, or the browser
doesn't sent the If-Modified-Since header. I know for a fact that
$HTTP_IF_MODIFIED_SINCE is the right variable to compare with.

I use apache under linux (and mysql), am i forgetting something
or do i have to set something in my conf file ?

Last Modified
I'm using a very simple Java Script that tells you the date and time the file was last modified. Code:

Getting The Last Modified Row In Mysql Db
Hello. I'm not sure if this should go in the MySQL forum but Oh well. Anyways I've got my webpage to display everything in my Databases table. I've use the following code->

<?php
$linkID = @mysql_connect("localhost", "INSERT YOUR DB USERNAME HERE", "INSERT YOUR DB PASSWORD HERE");
mysql_select_db("INSERT YOUR DB NAME HERE", $linkID);

$resultID = mysql_query("SELECT ibf_members.id, ibf_members.name, ibf_members.email FROM ibf_members", $linkID);

print "<table border=1><TR><TH>ID</TH>";
print "<TH>Name</TH><TH>Last Name</TH></TR>";

while ($row = mysql_fetch_row($resultID))
{
print "<TR>";
foreach ($row as $field)
{
print "<TD>$field</TD>";
}
print "</TR>";
}

print "</table>";

mysql_close($linkID);

?>

But I want it to display the row that was modified last.
I've searched through my php book and looked at all the commands it offers but I didn't find anything that would relate to what I want to happen. So I just want to know what the function is to display -- or at least dump the last modified row into a variable.

Another Last Modified Question
So a while back I started parsing .htm/.html files as php so I could include some php code snippets within my pages while appearing as static pages.

With that I recently found that I no longer generate any cache headers.

I did some research and found that I can include :

<?php header("Last-Modified: " . gmdate("D, d M Y H:i:s", getlastmod()) . " GMT");?>

at the top of every page. I then validate this with a header check tool online with a few pages I was testing on. While the last modified date does show now it NEVER returns a 304 which is the entire purpose of this. It is ALWAYS 200.

Here is an example of my output from the test :

#1 Server Response: http://www.foo.com/test.htm
HTTP Status Code: HTTP/1.1 200 OK
Date: Wed, 27 Dec 2006 07:24:39 GMT
Server: Apache/1.3.36 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.4.2 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.27 OpenSSL/0.9.7a
X-Powered-By: PHP/4.4.2
Last-Modified: Wed, 27 Dec 2006 07:15:07 GMT
Connection: close
Content-Type: text/html

Now, shouldn't this be returning 304 to me after it has been cached locally on my machine?

Second question - is it worth creating an etag along with this? What about some of the other cache controls out there? Basically, my only reason for this currently is to comply a little better and save some bandwith. My pages rarely change, but when they ARE updated I would like places like Google to know about it.

If-modified-since HTTP Compliant!
is there a HTTP-compliant implementation of If-Modified-Since-, If-Match,
If-None-Match, If-Range and so on?

I want my PHP-script to act exactly as if it was a static HTML-page
delivered directly from Apache.

I think this isn't easy to implement, especially if you take also weak and
strong validators into account.


Show When The Page Has Been Last Modified
1. I have php script that will show when the page has been last modified. How do I link it on my home page. The link that I am using now does not work. Here is the link:
<? include("updatepage.php"); ?>

2. I have a php forum. When I link it this way <a href="xxxxx/index.php"> it brings up the source code. When I link it this way <a href="xxxxxx/"> it brings up the dir. When I link it this way <a href="http://xxx/xxxxx/index.php"> it works. How do I get it to work with this linking <a href="xxxxxx/index.php">

Header Last Modified Time
For some reason, when you view the http header info for my .php pages, it does not show a last modified date and time. So, thinking that I could create one, I tried this:

<?php header("Last-Modified: ".filectime($_SERVER['PHP_SELF']); ?>
but it doesn't work. Does anyone know how to do what I am trying to do?

Displaying A File Path
Does anyone know how (in PHP) you can display the path of the current file? ex. (Home > PHP > Templates).I know you can do it in JavaScript, but I'd prefer to use PHP.

Echo The Last Time Directory Was Modified..
I want to do the following in a PHP script: Get the time at which a directory was last modified, and then, if it was within the last 30 days, echo that time.

Displaying Records From Text File
I have the following Code which reads in information from a text file: PHP Code:

Displaying Text With Include File.
Given this html code page;
======begin
<html>
<body>
<!--#include file="outing.1.shtml"-->
<form action="form.php" method="GET">
<input type="hidden" name="op" value="ds">
<table width="468" border="0" cellspacing="0" cellpadding="0">
<tr>
<input type="hidden" name="id[1]" value="1">
<td>Name<input name="name[1]" type="text" size="30"></td>
<td>Email<input name="email[1]" type="text" size="60"></td>
<td>Phone<input name="phone[1]" type="text" size="15"></td>
</tr>
</table>
<input type="submit" name="submit" value="submit">
</form>

</body>
</html>
===========end
and this php code page;
==========begin
form.php
<?php
if($_GET["op"] == "ds") {
foreach ($_GET["name"] as $key=>$value) {
echo $_GET["name"][$key] ."-". $_GET["email"][$key] ."-".
$_GET["phone"][$key] ."-". $_GET["id"][$key];

$fp=fopen("outing.1.shtml","a");
fwrite($fp,$_GET["name"][$key] ."-". $_GET["email"][$key] ."-".
$_GET["phone"][$key]);
fclose($fp);
}
}
?>
========end

Both of these are on my IP server, EV1.

I would like the contents of 'outing.1.shtml' to be displayed hence
the <!--#include file="outing.1.shtml"--in the HTML code.

Displaying Contents Of A Text File?
I'm trying grab the content of a text file and print it a web page. I believe that I should be using something along the lines of "file" or "fopen", but I'm not having any luck. Any thoughts or tips?

Problem When Displaying ' From An Ammended File
i have a problem i am using fwrite() to ammend a file and when i use include to display the file it shows all ' with a before it.

Text File Displaying On Screen
I have a file that downloaded a CSV file for the user based upon some
information gathered from the Database. My file was working fine until
recently (I believe that my hosting company did something when they
upgraded to PHP5). Everytime a user tries to download the file, it
displays the contents on the screen. Here is what I have for my file
handling. Am I missing anything obvious?

when called, $filecontent is displayed to the screen...

$downloadfile=$shownic."AttendeeRoster".time().".csv";
header("Content-disposition: attachment; filename=$downloadfile");
header("Content-type: text/css; charset=UTF-8");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".strlen($filecontent));
header("Pragma: no-cache");
header("Expires: 0");
echo $filecontent;

Displaying Data From A Flat File?
ive got a flatfile database sorted out, all i need now is how to store individual flat files per user and how to paginate that data. Just to make sure i'm doing everything right, i'll post the code below Code:

Wierd Characters When Displaying Content Of File
I have a txt file and when I display the content using echo some lines display correctly and some have wierd characters in between letters:

for example:

<?php
echo $lines[1];
echo $lines[2];

as a result I am getting correctly displayed first line:
1st line: Product A
2nd line: between each letter there is a square P(square)r(square)o(square)d(square) etc.

What should I do to display it correctly and why is it doing that?

Date Sorting From File
I am doing a flatfile calendar, and I need a way to display all activities for a whole year.
Each month has its own file, with the following layout

2003-09-01 Da message 0 // date message priotiry
2003-09-02 Das besked 1

My problem is that I need to somehow get this information and print it out in an order of date. The information is not saved in any order so I need to sort it in my code, My plan was to go through all the files (plain text), and collect the left side in one array and then sort it, then pair the right side with the correct date. Problem is, I don't know how to do that.

How To Display The Date Of A Php-file?
I'd like to display the actual date of a php-file (like: last changed at ...) ... how could i do this?=

Get Date From Text/php-file
I'm new to PHP, and i want to create a pop-up (on page load) on certain dates..
What i have is the script for the pop-up:

<body scroll="auto" <?php $today =date("d-F"); if ($today==$datum)
{echo "onLoad=".$g_birthday_pop;}?>>

The pop-script =
$g_birthday_pop = <<<EOT
"MM_openBrWindow('http://www.nu.nl','popup','width=300,height=300')"
EOT;

$datum is in another file (include/datum.php):
<?php
$datum= "30-December";
?>

And this works if the date is 30th of December,
but i want it too on other dates that you put in $datum
Something like:
<?php
$datum= "30-December";"10-March";
?>
So i want to control the pop-up just by editing the "datum.php"-file

Get Date From Text/php-file
I got it going.
Now i have another question;

Is there a way to link a date to a persons name,
so i can get the pop-up, and the pop-up
then automatically grabs the right name, and displays it?


File Last-modifed-date?
Is there a way the retrieve the last modified date of a certain file with PHP?

Finding Date File Created
What function will return the time a file was created? I see
filemtime(...) returns the time that file was last Modified and
fileatime(...) returns the time that a file was last accessed but what
about created?

Need PHP To Read File Date In Directory
Is there a way to use PHP to read the date of a file that is uploaded
into a directory and then print out that date on another page?

I'm looking to have a specific file (/texts/filename.pdf) located in the
directory and the date of its last change/modification printed into a
date("F, n, Y"); format on another page. I checked the PHP manual but
couldn't find any date/time functions that were what I needed.

Date From Form To File, Mail
I am trying to get a date stamp on the results from an HTML form. Through PHP3, my form writes a file or emails the results without the date and I would like to get the date in there. It is really simple, but I don't know how to do it.

Date And Filetime Of A HTTP-File
I want to transfer a file from a http-server to another.
Well, that goes fine like this:

$upload = ftp_put($conn_id, "$destination_file", "$source_file",
FTP_BINARY);

But I want - before the transfer - to know wether the $source_file exists.
More, I want to know and keep its original filetime.

I tried with file_exists. Don't work. So don't work fileatime etc. either.



Delete File (timestamp & Date Problem)
I want to delete a file which is modified at least 60 minutes ago. i failed to do it.i fetched the last modified timestamp using filectime() or filemtime. but how can compare if it is last modified at 60 mins ago?

Function That Returns Date Of File Last Updated
Is there a PHP function that can reference a file and return the date that the file was last updated?

Pulling Date-specific Data From Flat File
I'm almost a complete newbie to using PHP and I was hoping one of you
guys can point me in the right direction. I'm working on a site for a
brand of handmade fruit juice and it only needs one bit of dynamic
content: the info on what fruit is in the juice and where it is coming
from (vendor, country etc.) today and tomorrow (the content of the
juice is different everyday). So I thought it would be easiest to put
that information in a flat file (an Excel file would be ideal but a
plain text would do too) on a weekly basis and try to pull out the
needed info with PHP. Except I don't know how yet. I don't expect any
of you to do the work for me but if someone could point me to which
functions of PHP I should do some research on, I'd be most grateful.

What Should I Use To Set Up Modified "Calendar" Form?
I have events that take place every Monday, Wednesday, Saturday, and Sunday, and I want to generate my copy--which is the same for most events--and my printed schedule from a php form.

My plan is to first generate a form that lists pulldown boxes for each of those days in the next month--I could specify the month, but I don't think that fits my bill, and then utilize the pulldowns to set the events.

However, I'm not sure where to begin to return just the days I need...should I use getdate() as my basis for this?  From what I'm reading, it seems right, but I'm not sure.


Copyright © 2005-08 www.BigResource.com, All rights reserved