Display datestamp script in HTML 
March 2nd, 2007, 05:05 PM
| | | Display datestamp script in HTML
Hi all. I have am HTML web page where I upload an updated 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 scripts 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. What code do I
have to paste in the index.html to display the actual datestamp of
document.html? The server is Apache 1.3.26
I was able to find the following code, but this displays the
modification date of the HTML file itself, not from another file.
<!--#config timefmt="%B %e, %Y"-->
<script type="text/javascript">
//Page Last Modified Date script- By JavaScriptKit.com
//Visit http://www.javascriptkit.com for full source code
//This notice must stay intact for use
var docmodified='<!--#echo var="LAST_MODIFIED" -->'
document.write('This page was last modified: '+docmodified)
</script>
Thanks for any suggestions! | 
March 2nd, 2007, 08:25 PM
| | | Re: Display datestamp script in HTML
While the city slept, Phil M (jimmyc@trexagi.net) feverishly typed... Quote:
Hi all. I have am HTML web page where I upload an updated 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
>
| [...] Quote:
>
I was able to find the following code, but this displays the
modification date of the HTML file itself, not from another file.
| [...]
Most likely because the javascript runs on the client, but you need
information about a file on the server. You could do this with some pretty
simple PHP which runs on the server-side. Something like, in your
index.html;
<!-- Start of example -->
<p><a href="document.pdf>document.pdf</a(last modified:
<? php
echo date("F d Y H:i:s.", filemtime("document.pdf"));
?>
)</p>
<!-- end of example -->
.... and rename your index.html to index.php...
I would recommend doing a test version first though just to make sure...
Hope that helps.
Nige
--
Nigel Moss http://www.nigenet.org.uk
Mail address will bounce. nigel@DOG.nigenet.org.uk | Take the DOG. out!
"Your mother ate my dog!", "Not all of him!" | 
March 2nd, 2007, 08:35 PM
| | | Re: Display datestamp script in HTML
While the city slept, nice.guy.nige (nigel_moss@deadspam.com) feverishly
typed... Quote:
<!-- Start of example -->
>
<p><a href="document.pdf>document.pdf</a(last modified:
<? php
echo date("F d Y H:i:s.", filemtime("document.pdf")); | That last should be a question mark (?) followed by a right angled bracket
(>) as in ?>... but my newsreader decided to ditch the question mark... Just
to clarify.
Cheers,
Nige
--
Nigel Moss http://www.nigenet.org.uk
Mail address will bounce. nigel@DOG.nigenet.org.uk | Take the DOG. out!
"Your mother ate my dog!", "Not all of him!" | 
March 2nd, 2007, 09:05 PM
| | | Re: Display datestamp script in HTML
>simple PHP which runs on the server-side. Something like, in your Thanks for the code. As per the suggestion, I uploaded this: http://www.greekradio.net/psa.php
and gives a parse error
in case you can't see the source code here it is again in plian text: http://www.greekradio.net/psa.txt
the page should look someting like this (plus the datestamp I'm trying
to include)
Thanks for any suggestions. | 
March 2nd, 2007, 09:05 PM
| | | Re: Display datestamp script in HTML
the page should look someting like this (plus the datestamp I'm trying
to include) http://www.greekradio.net/psa.html | 
March 3rd, 2007, 12:45 PM
| | | Re: Display datestamp script in HTML
While the city slept, Phil M (jimmyc@trexagi.net) feverishly typed... [...]
My mistake, sorry... take out the space between the <? and php, so it reads
<?php instead of <? php...
(hangs head in shame!)
Cheers,
Nige
--
Nigel Moss http://www.nigenet.org.uk
Mail address will bounce. nigel@DOG.nigenet.org.uk | Take the DOG. out!
"Your mother ate my dog!", "Not all of him!" | 
March 3rd, 2007, 04:05 PM
| | | Re: Display datestamp script in HTML
Nige,
To recapitulate, this is the code I have right now:
<!-- Start of example -->
<p><a href="document.pdf">document.pdf</a(last modified:
<?php
echo date("F d Y H:i:s.", filemtime("document.pdf"));
?>
)</p>
<!-- end of example --></p>
the result is this: http://www.greekradio.net/psa.html
It doesn't display the date.
Thanks for any suggestion. | 
March 3rd, 2007, 04:15 PM
| | | OT, PHP Solution To Problem (was Re: Display datestamp script in HTML)
While the city slept, Phil M (jimmyc@trexagi.net) feverishly typed...
[...] Change the filename to psa.php.
Hope that helps.
Cheers,
Nige
--
Nigel Moss http://www.nigenet.org.uk
Mail address will bounce. nigel@DOG.nigenet.org.uk | Take the DOG. out!
"Your mother ate my dog!", "Not all of him!" | 
March 3rd, 2007, 04:25 PM
| | | Re: Display datestamp script in HTML
On Sat, 03 Mar 2007 17:57:07 +0100, Phil M <jimmyc@trexagi.netwrote: Quote:
Nige,
>
To recapitulate, this is the code I have right now:
>
<!-- Start of example -->
>
<p><a href="document.pdf">document.pdf</a(last modified:
<?php
echo date("F d Y H:i:s.", filemtime("document.pdf"));
?>
)</p>
>
<!-- end of example --></p>
>
the result is this:
> http://www.greekradio.net/psa.html
>
It doesn't display the date.
>
Thanks for any suggestion.
| Maybe the document isn't as local as you think? Did you try
filemtime("./document.pdf")? On some servers you have to tell the parser
which directory to use. ./ should have the parser choose the same
directory as the script.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ | 
March 3rd, 2007, 04:45 PM
| | | Re: Display datestamp script in HTML
Did you try filemtime("./document.pdf")?
Thanks for the suggestion; I just tried the ./
I don't think that's the problem as the above code prints the file
link instead of the date, as shown here: http://www.greekradio.net/psa.html | 
March 3rd, 2007, 04:45 PM
| | | Re: Display datestamp script in HTML
While the city slept, Phil M (jimmyc@trexagi.net) feverishly typed... Quote:
Thanks for the suggestion; I just tried the ./
I don't think that's the problem as the above code prints the file
link instead of the date, as shown here: http://www.greekradio.net/psa.html | Did you change the file extension from .html to .php as I suggested in my
post?
Cheers,
Nige
--
Nigel Moss http://www.nigenet.org.uk
Mail address will bounce. nigel@DOG.nigenet.org.uk | Take the DOG. out!
"Your mother ate my dog!", "Not all of him!" | 
March 3rd, 2007, 05:05 PM
| | | Re: Display datestamp script in HTML
>Did you change the file extension from .html to .php as I suggested in my
Nige,
Thanks for the tip(s). After renaming the html to php IT WORKED!
here: http://www.greekradio.net/psa.php
Isn't there any way to have this code with an html extension? If not,
I'm not worried. As long as it works I'm happy with that. Thanks!
Also, you may want to make this small and very efficient code
available also in a pool 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. Thanks. | 
March 3rd, 2007, 07:15 PM
| | | Re: Display datestamp script in HTML
In comp.lang.javascript message <d0pgu29t0pqeinrr25g4psg18t5hbg3i37@4ax.
com>, Fri, 2 Mar 2007 12:55:24, Phil M <jimmyc@trexagi.netposted: Quote:
>Hi all. I have am HTML web page where I upload an updated 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?
| That's susceptible to misleading if the PDF is ever re-uploaded without
significant change.
If you always ALSO upload to the same directory a file called
document.js containing the line
document.writeln("Date of document.pdf is YYYY-MM-DD")
with the YYYY-MM-DD always set correctly, then the desired date should
appear where you put
<script type="text/javascript" src="document.js"></scriptin your Web
page.
Maybe you can automate the generation of document.js .
It's a good idea to read the newsgroup and its FAQ. See below.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links. | 
March 3rd, 2007, 08:35 PM
| | | Re: Display datestamp script in HTML
>If you always ALSO upload to the same directory a file called Quote: |
>document.js containing the line
| Thank you for your suggestion. I'll give it a try. | 
March 3rd, 2007, 08:55 PM
| | | Re: Display datestamp script in HTML
While the city slept, Dr J R Stockton (reply0709@merlyn.demon.co.uk)
feverishly typed...
[document last saved] Quote:
That's susceptible to misleading if the PDF is ever re-uploaded
without significant change.
| Possibly, but then, what would an insignificant change be? Quote:
If you always ALSO upload to the same directory a file called
document.js containing the line
>
document.writeln("Date of document.pdf is YYYY-MM-DD")
>
| [...]
Why would you want to suggest a javascript solution that relies on
javascript being available *and* enabled in the end-users client, when a
perfectly servicable php solution (which will serve the date to the end-user
without the need for javascript to be available and enabled) has been
offered to and used by the OP? Other than this being a javascript NG of
course...
Cheers,
Nige
--
Nigel Moss http://www.nigenet.org.uk
Mail address will bounce. nigel@DOG.nigenet.org.uk | Take the DOG. out!
"Your mother ate my dog!", "Not all of him!" | 
March 3rd, 2007, 09:15 PM
| | | Re: Display datestamp script in HTML
While the city slept, Phil M (jimmyc@trexagi.net) feverishly typed... Quote: Quote:
>Did you change the file extension from .html to .php as I suggested
>in my
| >
Nige,
>
Thanks for the tip(s). After renaming the html to php IT WORKED!
here: http://www.greekradio.net/psa.php | Great! Glad to hear (or more properly, read) it. Quote:
Isn't there any way to have this code with an html extension? If not,
I'm not worried. As long as it works I'm happy with that. Thanks!
| No, at least not without some serious tinkering with config files...
However, .php files are more than perfectly acceptable. Of course, there may
be an issue with persons who have bookmarked your .html version. In this
case, it is fairly simple to write a basic redirect for your apache server
so that any requests for psa.html get redirected to psa.php.
Cheers,
Nige
--
Nigel Moss http://www.nigenet.org.uk
Mail address will bounce. nigel@DOG.nigenet.org.uk | Take the DOG. out!
"Your mother ate my dog!", "Not all of him!" | 
March 4th, 2007, 07:15 PM
| | | Re: Display datestamp script in HTML
In comp.lang.javascript message <45e9ec84$0$97266$892e7fe2@authen.yellow
..readfreenews.net>, Sat, 3 Mar 2007 21:44:44, nice.guy.nige
<nigel_moss@deadspam.composted: Quote:
>While the city slept, Dr J R Stockton (reply0709@merlyn.demon.co.uk)
>feverishly typed...
>
>[document last saved] Quote:
>That's susceptible to misleading if the PDF is ever re-uploaded
>without significant change.
| >
>Possibly, but then, what would an insignificant change be?
| Change of location (URL); correction of spelling mistakes; ... Quote: Quote:
>If you always ALSO upload to the same directory a file called
>document.js containing the line
>>
> document.writeln("Date of document.pdf is YYYY-MM-DD")
>>
| >[...]
>
>Why would you want to suggest a javascript solution that relies on
>javascript being available *and* enabled in the end-users client, when a
>perfectly servicable php solution (which will serve the date to the end-user
>without the need for javascript to be available and enabled) has been
>offered to and used by the OP? Other than this being a javascript NG of
>course...
| The OP asked in a javascript newsgroup and was obviously considering the
possibility of a javascript solution. Whether you like it or not, many
Web pages do require javascript; and for those there can be no rational
objection to using javascript a bit more.
This is a discussion group; if I had wanted my response not to be
available to others, I would not have posted it in News. Designers of
professional sites would have and use PHP; but not everyone has PHP
available or wants to learn it.
News is not a synchronous medium; one should not presume from the
datestamp of an article that it will have reached all other readers soon
after.
The technique is adaptable for other purposes.
It's a good idea to read the newsgroup and its FAQ. See below.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links. | 
March 4th, 2007, 08:35 PM
| | | Re: Display datestamp script in HTML
While the city slept, Dr J R Stockton (reply0709@merlyn.demon.co.uk)
feverishly typed... Quote:
The OP asked in a javascript newsgroup and was obviously considering
the possibility of a javascript solution. Whether you like it or
not, many Web pages do require javascript; and for those there can be
no rational objection to using javascript a bit more.
| I agree that many web pages do require javascript for effects that cannot be
supplied by HTML, styling, or server-side processing. But these effects
should not diminish the page if javascript is not available - eg, it should
not be relied upon to provide content. I'm talking about the concept of
"graceful degradation" here. The result that the OP was after was -- IMHO --
best served by a server-side process, as this would have direct access to
the file information he needed. The fact that he asked in a javascript
newsgroup was -- again, IMHO -- because he wasn't necessarily aware that
there would be any other way of doing it, and he had found what he thought
would be a javascript solution which in actual fact wasn't so he asked in
this group to see if it could be made to work. Quote:
This is a discussion group; if I had wanted my response not to be
available to others, I would not have posted it in News. Designers of
professional sites would have and use PHP; but not everyone has PHP
available or wants to learn it.
| Accepted. It is quite true that not all users of this group will have
server-side scripting available to them (although availability of
fuller-featured hosting is a lot cheaper these days), so your solution would
indeed provide a suitable answer to those people. To the others I would
recommend learning server-side scripting such as PHP in any case... as long
as there is space on their "To-do" list of course! Quote:
News is not a synchronous medium; one should not presume from the
datestamp of an article that it will have reached all other readers
soon after.
| Accepted. I didn't notice the posting date/time of your message until after
I had made my reply, and I apologise for that. Quote: |
The technique is adaptable for other purposes.
| Indeed, as are most techniques. The beauty of the medium is that a solution
to an otherwise unconnected issue can provide the inspiration to solve a
separate problem of your own... of the "something like that might work for
the problem I've been having" type. Quote: |
It's a good idea to read the newsgroup and its FAQ. See below.
| I haven't been on this newsgroup for sometime and returned recently as I was
trying to implement a DHTML calendar plugin that wasn't playing ball. Fun to
be back, and to see some familiar names. Talking of names, does Jim not do
the FAQ's any more? Seeing some guy called "Randy" is FAQEditor, although I
see the FAQ's are still on jibbering.com.
Cheers,
Nige
--
Nigel Moss http://www.nigenet.org.uk
Mail address will bounce. nigel@DOG.nigenet.org.uk | Take the DOG. out!
"Your mother ate my dog!", "Not all of him!" | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 220,989 network members.
|