display datestamp in HTML

P

Phil M

Hi all. I have am HTML web page where I upload a file which is always
called document.pdf. Users get there, click on the icon and download
the document.pdf.

Below the icon/link where users click to get document, is there any
way to display the datestamp of document.pdf?

ie: the document you're about to download was updated: March 2 2007

My web page file name is called index.html (page where I want the
datestamp to de displayed)
The directory where I can store perl scripts (in .pl) is called /bin
The file from which I want the datestamp to be retrieved is called
document.pdf

I searched the Internet for such a simple script but couldn't find
any. I'm not a programmer, so please bear with me. Assume I find a
pl script which captures the datestamp of document.pdf, all I know is
that I have to modify the header of the .pl file to read:
#!/usr/bin/perl then upload it in /bin

THEN, what code do I have to paste in the index.html to print the
actual datestamp? The server is Apache 1.3.26

Thanks for any suggestions!
 
T

Tony Curtis

Phil said:
Hi all. I have am HTML web page where I upload a file which is always
called document.pdf. Users get there, click on the icon and download
the document.pdf.

Below the icon/link where users click to get document, is there any
way to display the datestamp of document.pdf?

If the modification date of the file is what you want as the actual
document modification date, then SSI would be a much simpler solution,
but nothing to do with perl.

hth
t
 
P

Phil M

Thanks for the quick reply. It can be either. Modification date,
upload date or file date or creation date; whatever is simpler.

Either the file datestamp (as it appears next to the filename when I
log in to the ftp web server) or the date which it was uploaded. it
doesn't matter since the date that I create the pdf file I also upload
it; so creation/modification/upload date is the same.
 
P

Phil M

then SSI would be a much simpler solution

Thanks, I'll ask the same question on a SSI Javascript group.
 
P

Phil M

I found a small perl script which claims to do the trick and it seems
that I can't get the code right:

Here's my web page: (note that the date doesn't appear)
http://www.greekradio.net/psa.html

This is the script: (stored in cgi/lastmodified.pl)


#!/usr/bin/perl

# Script name:
# @1 Last Modified Date and Time

# Purpose:
# This Perl script checks the "Last Modified" date and time
# of a file.

# Uses:
# Call the display via SSI using the tag below:
# <!--#include virtual="yourfolder1/yourfolder2/lastmodified.cgi" -->

# License Notice:
# Copyright 2004 UPDI Network Enterprise, www.upoint.info/cgi
# You are free to use and distribute this script as long as
# you keep this license notice intact.

############################################################
# FULL PATH (not URL) to the file:
############################################################
$filename = "/hrnet/u/chrb/www/ekm_psa/document.pdf";

############################################################
# Turn on debug mode so that you can see the formats
############################################################
$debug = "0"; # 1 = ON 0 = OFF
# Set to "0" after testing
############################################################
# DO NOT EDIT BELOW THIS LINE
############################################################

use POSIX 'strftime';
my $time = (stat $filename)[9];
print "Content-type: text/html\n\n";

print strftime '%a %d.%b.%Y @ %I:%M %p', localtime $time;

if ($debug eq 1){
print "<p>";
print "a - ";
print strftime '%a', localtime $time;
print "<BR>";
print "A - ";
print strftime '%A', localtime $time;
print "<BR>";
print "b - ";
print strftime '%b', localtime $time;
print "<BR>";
print "B - ";
print strftime '%B', localtime $time;
print "<BR>";
print "c - ";
print strftime '%c', localtime $time;
print "<BR>";
print "d - ";
print strftime '%d', localtime $time;
print "<BR>";
print "H - ";
print strftime '%H', localtime $time;
print "<BR>";
print "I - ";
print strftime '%I', localtime $time;
print "<BR>";
print "j - ";
print strftime '%j', localtime $time;
print "<BR>";
print "m - ";
print strftime '%m', localtime $time;
print "<BR>";
print "M - ";
print strftime '%M', localtime $time;
print "<BR>";
print "p - ";
print strftime '%p', localtime $time;
print "<BR>";
print "s - ";
print strftime '%s', localtime $time;
print "<BR>";
print "U - ";
print strftime '%U', localtime $time;
print "<BR>";
print "w - ";
print strftime '%w', localtime $time;
print "<BR>";
print "W - ";
print strftime '%W', localtime $time;
print "<BR>";
print "x - ";
print strftime '%x', localtime $time;
print "<BR>";
print "X - ";
print strftime '%X', localtime $time;
print "<BR>";
print "y - ";
print strftime '%y', localtime $time;
print "<BR>";
print "Y - ";
print strftime '%Y', localtime $time;
print "<BR>";
print "Z - ";
print strftime '%Z', localtime $time;
}

Thanks for any suggestions on what I might be doing wrong.
 
M

Mumia W.

Hi all. I have am HTML web page where I upload a file which is always
called document.pdf. Users get there, click on the icon and download
the document.pdf.

Below the icon/link where users click to get document, is there any
way to display the datestamp of document.pdf?

ie: the document you're about to download was updated: March 2 2007
[...]

This is how you might find out the datestamp:

use POSIX qw(asctime);
my $filename = 'my.flat';
print asctime(localtime((stat $filename)[9]));

Read the documentation for asctime and stat. I'm assuming that you're a
Windows user:

Start->Run->"perldoc POSIX"
Start->Run->"perldoc -f stat"

After you have the datestamp in a string, printing it should be
elementary. Good luck.
 
A

anno4000

Phil M said:
I found a small perl script which claims to do the trick and it seems
that I can't get the code right:

Then show your code. We can't help you with what we don't get to see.
Here's my web page: (note that the date doesn't appear)
http://www.greekradio.net/psa.html

How about saying *where* the date is supposed to appear?
This is the script: (stored in cgi/lastmodified.pl)

#!/usr/bin/perl

# Script name:
# @1 Last Modified Date and Time

# Purpose:
# This Perl script checks the "Last Modified" date and time
# of a file.

# Uses:
# Call the display via SSI using the tag below:
# <!--#include virtual="yourfolder1/yourfolder2/lastmodified.cgi" -->

# License Notice:
# Copyright 2004 UPDI Network Enterprise, www.upoint.info/cgi
# You are free to use and distribute this script as long as
# you keep this license notice intact.

############################################################
# FULL PATH (not URL) to the file:
############################################################
$filename = "/hrnet/u/chrb/www/ekm_psa/document.pdf";

############################################################
# Turn on debug mode so that you can see the formats
############################################################
$debug = "0"; # 1 = ON 0 = OFF
# Set to "0" after testing
############################################################
# DO NOT EDIT BELOW THIS LINE
############################################################

use POSIX 'strftime';
my $time = (stat $filename)[9];
print "Content-type: text/html\n\n";

print strftime '%a %d.%b.%Y @ %I:%M %p', localtime $time;

if ($debug eq 1){
print "<p>";
print "a - ";
print strftime '%a', localtime $time;
print "<BR>";
print "A - ";
print strftime '%A', localtime $time;
print "<BR>";
print "b - ";
print strftime '%b', localtime $time;
print "<BR>";
print "B - ";
print strftime '%B', localtime $time;
print "<BR>";
print "c - ";
print strftime '%c', localtime $time;
print "<BR>";
print "d - ";
print strftime '%d', localtime $time;
print "<BR>";
print "H - ";
print strftime '%H', localtime $time;
print "<BR>";
print "I - ";
print strftime '%I', localtime $time;
print "<BR>";
print "j - ";
print strftime '%j', localtime $time;
print "<BR>";
print "m - ";
print strftime '%m', localtime $time;
print "<BR>";
print "M - ";
print strftime '%M', localtime $time;
print "<BR>";
print "p - ";
print strftime '%p', localtime $time;
print "<BR>";
print "s - ";
print strftime '%s', localtime $time;
print "<BR>";
print "U - ";
print strftime '%U', localtime $time;
print "<BR>";
print "w - ";
print strftime '%w', localtime $time;
print "<BR>";
print "W - ";
print strftime '%W', localtime $time;
print "<BR>";
print "x - ";
print strftime '%x', localtime $time;
print "<BR>";
print "X - ";
print strftime '%X', localtime $time;
print "<BR>";
print "y - ";
print strftime '%y', localtime $time;
print "<BR>";
print "Y - ";
print strftime '%Y', localtime $time;
print "<BR>";
print "Z - ";
print strftime '%Z', localtime $time;
}

Which garbage dump did you search to find this "script"? The author
doesn't have the slightest idea about programming, let alone Perl.
Programming is, among other things, about letting the computer do
the work.

Stripped of its pompous commentary and its pathetically repetitious
code, replace the whole thing by this:

#!/usr/bin/perl
use strict; use warnings;
use POSIX 'strftime';

my $filename = "/hrnet/u/chrb/www/ekm_psa/document.pdf";

my $debug = 1;
my $time = (stat $filename)[9] or die "Can't stat '$filename': $!";

print "Content-type: text/html\n\n";

print strftime '%a %d.%b.%Y @ %I:%M %p', localtime $time;

if ( $debug ) {
my $fmt = '<p>' . join '<BR>', map "$_ - %$_",
qw( a A b B c d H I j m p s U w W x X y Y Z);
print strftime $fmt, localtime $time;
}
__END__
Thanks for any suggestions on what I might be doing wrong.

You're not showing what you're doing. How can we say what you're doing
wrong?

Anno
 
P

Phil M

Stripped of its pompous commentary and its pathetically repetitious
code, replace the whole thing by this:

Anno,

YOUR CODE WORKED! here:
http://s135598769.onlinehome.us/greekradio/psa.shtml

However, I had to rename the file with a .shtml to work. Is there any
way to keep the .html extension?

Also, you may want to make this small and very efficient code
available somewhere because it may find good use among people with
webcams. For example, every time a webcam a photo is uploaded, you
code will display the datestamp and timestamp of the photo, rather
than the date/time of the web page. Good work!

Please inform for the .shtml issue.

Thanks again.
 
J

Joe Smith

Phil said:
However, I had to rename the file with a .shtml to work. Is there any
way to keep the .html extension?

You'll have to ask the person who controls the configuration file for
the web server. If they don't allow individual .htaccess files, the
answer is "no".
-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top