Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > display datestamp in HTML

Reply
Thread Tools

display datestamp in HTML

 
 
Phil M
Guest
Posts: n/a
 
      03-02-2007
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!
 
Reply With Quote
 
 
 
 
Tony Curtis
Guest
Posts: n/a
 
      03-02-2007
Phil M wrote:
> 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
 
Reply With Quote
 
 
 
 
Phil M
Guest
Posts: n/a
 
      03-02-2007
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.

>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.

 
Reply With Quote
 
Phil M
Guest
Posts: n/a
 
      03-02-2007
> then SSI would be a much simpler solution

Thanks, I'll ask the same question on a SSI Javascript group.
 
Reply With Quote
 
Phil M
Guest
Posts: n/a
 
      03-02-2007
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.
 
Reply With Quote
 
Phil M
Guest
Posts: n/a
 
      03-02-2007
I also saved the file as an shtml, same results:

http://www.greekradio.net/psa.shtml
 
Reply With Quote
 
Mumia W.
Guest
Posts: n/a
 
      03-02-2007
On 03/02/2007 10:40 AM, Phil M wrote:
> 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.
 
Reply With Quote
 
anno4000@radom.zrz.tu-berlin.de
Guest
Posts: n/a
 
      03-03-2007
Phil M <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> 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
 
Reply With Quote
 
Phil M
Guest
Posts: n/a
 
      03-03-2007
>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.
 
Reply With Quote
 
Joe Smith
Guest
Posts: n/a
 
      05-18-2007
Phil M wrote:

> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Datestamp on Olympus Stylus mju 720/725/770 sw The One Digital Photography 2 07-20-2007 05:47 AM
Display datestamp script in HTML Phil M Javascript 17 03-04-2007 09:23 PM
Removing Datestamp bilvihur@localnet.com Digital Photography 6 08-11-2005 10:21 AM
How to get prints with a datestamp on them Michael Poole Digital Photography 2 08-01-2005 12:52 AM
MMYYYY - datestamp Zee Zop Perl 5 10-01-2004 08:48 PM



Advertisments