Discussion:
get pages age
(too old to reply)
Ed Mullen
2017-07-09 23:17:08 UTC
Permalink
So, let's say we have a site with x pages and we would like to create a
list of the pages ordered by their last modified date.

How to do using any method, maybe PHP.

BTW, each page on the site contains this footer code:

<?php
$current_file_name = ($_SERVER['REQUEST_URI']);
$current_path = ($_SERVER['DOCUMENT_ROOT']);
$full_name = $current_path.$current_file_name;
$last_modified = filemtime($full_name);
print("This page last changed: ");
print(date("F j, Y - h:i A", $last_modified));
print(" USA Eastern Time");
?>

which displays the last modified date of each page. Not sure if that
even is relevant.
--
Ed Mullen
http://edmullen.net/
What is a free gift? Aren't all gifts free?
J.O. Aho
2017-07-10 05:00:07 UTC
Permalink
Post by Ed Mullen
So, let's say we have a site with x pages and we would like to create a
list of the pages ordered by their last modified date.
How to do using any method, maybe PHP.
<?php
$current_file_name = ($_SERVER['REQUEST_URI']);
$current_path = ($_SERVER['DOCUMENT_ROOT']);
$full_name = $current_path.$current_file_name;
$last_modified = filemtime($full_name);
print("This page last changed: ");
print(date("F j, Y - h:i A", $last_modified));
print(" USA Eastern Time");
?>
which displays the last modified date of each page. Not sure if that
even is relevant.
I'm assuming that your pages are including all the content which is
static instead of fetching the dynamic data from a database.

Then you need to begin with list all the pages, you can use the dir()
function ( http://php.net/manual/en/function.dir.php ) and get the
filetime() for each file, store those in an array with the time in
unixtime as the key and the filename as the value, this requires that
each file has it's unique time, or else you need to have an array of
file names instead of a single value. Then user ksort (
http://php.net/manual/en/function.ksort.php ) to sort the values, use
the numeric sorting.
--
//Aho
Ed Mullen
2017-07-10 14:43:05 UTC
Permalink
On 7/10/17 at 1:00 AM, J.O. Aho's prodigious digits fired off with great
Post by J.O. Aho
Post by Ed Mullen
So, let's say we have a site with x pages and we would like to create a
list of the pages ordered by their last modified date.
How to do using any method, maybe PHP.
<?php
$current_file_name = ($_SERVER['REQUEST_URI']);
$current_path = ($_SERVER['DOCUMENT_ROOT']);
$full_name = $current_path.$current_file_name;
$last_modified = filemtime($full_name);
print("This page last changed: ");
print(date("F j, Y - h:i A", $last_modified));
print(" USA Eastern Time");
?>
which displays the last modified date of each page. Not sure if that
even is relevant.
I'm assuming that your pages are including all the content which is
static instead of fetching the dynamic data from a database.
Then you need to begin with list all the pages, you can use the dir()
function ( http://php.net/manual/en/function.dir.php ) and get the
filetime() for each file, store those in an array with the time in
unixtime as the key and the filename as the value, this requires that
each file has it's unique time, or else you need to have an array of
file names instead of a single value. Then user ksort (
http://php.net/manual/en/function.ksort.php ) to sort the values, use
the numeric sorting.
Thanks for the info. I'll look into it.
--
Ed Mullen
http://edmullen.net/
All of us could take a lesson from the weather. It pays no attention to
criticism.
r***@gmail.com
2019-12-19 12:44:57 UTC
Permalink
Post by Ed Mullen
So, let's say we have a site with x pages and we would like to create a
list of the pages ordered by their last modified date.
How to do using any method, maybe PHP.
<?php
$current_file_name = ($_SERVER['REQUEST_URI']);
$current_path = ($_SERVER['DOCUMENT_ROOT']);
$full_name = $current_path.$current_file_name;
$last_modified = filemtime($full_name);
print("This page last changed: ");
print(date("F j, Y - h:i A", $last_modified));
print(" USA Eastern Time");
?>
which displays the last modified date of each page. Not sure if that
even is relevant.
--
Ed Mullen
http://edmullen.net/
What is a free gift? Aren't all gifts free?
I thought before, that it was impossible to get this.

--
Kristjan Robam

Magic spell to get what ever you need: I give because I'm generous. I take b. I ask What I well deserve is what I will get. I d. * I ne. * I will get *, so be it and so it is
Loading...