Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

get pages age

14 views
Skip to first unread message

Ed Mullen

unread,
Jul 9, 2017, 7:17:11 PM7/9/17
to
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

unread,
Jul 10, 2017, 1:00:10 AM7/10/17
to
On 07/10/17 01:17, Ed Mullen wrote:
> 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.
>

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

unread,
Jul 10, 2017, 10:43:07 AM7/10/17
to
On 7/10/17 at 1:00 AM, J.O. Aho's prodigious digits fired off with great
aplomb:
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.

robamm...@gmail.com

unread,
Dec 19, 2019, 7:44:59 AM12/19/19
to
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
0 new messages