Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
"Date Modified" code is not yielding the proper results
Old 03-12-2009, 09:54 PM "Date Modified" code is not yielding the proper results
Novice Talker

Posts: 10
Trades: 0
I have placed the following code:

<!-- Start Date Modified code -->
<div align="center"><font size="1" face="Arial, Helvetica, sans-serif">
<SCRIPT LANGUAGE="JavaScript">
<!--
var date
date=document.lastModified
document.write("Last Modified on "+date)
// -->
</SCRIPT>
</font></div>
<!-- End Date Modified code -->

at the bottom of my web site page at:

http://harry.cckerala.com/90s/download.php

Which appears as below:

Last modified on Thursday, March 12, 2009
Sprang into existence on September 2, 1998

It used to work. But, now, it indicates the day on which the person arrives at the page - not the date on which I modified it, as it should be! I have a different code on some of my other pages to do this function, but the end result is the same. Any ideas?

TIA.
Harry
<removed>

Last edited by chrishirst; 03-13-2009 at 04:56 AM..
Musicollector is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-13-2009, 04:57 AM Re: "Date Modified" code is not yielding the proper results
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Any pages that are scripted will always the current date as last modified.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-13-2009, 10:32 PM Re: "Date Modified" code is not yielding the proper results
Novice Talker

Posts: 10
Trades: 0
Perhaps, I did not make myself clear.

If you scroll down to the bottom of my main page at: http://harry.cckerala.com/

You will see that I have a Java script there, as well, which behaves correctly. As the website owner, I modified it on March 10 and you will see it as such. Ideally, that will remain as is until I modify it the next time. Every time a visitor on the Web loads the page, it is not supposed to change to the time of the visit.

On the contrary, if you go to the page with the problem at: http://harry.cckerala.com/90s/download.php

and scroll to the bottom, you will see that it gives you TODAY's date, when in fact, I have not touched that page today at all. Seems to be a dynamic script.

Harry
Musicollector is offline
Reply With Quote
View Public Profile
 
Old 03-13-2009, 10:39 PM Re: "Date Modified" code is not yielding the proper results
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
does the page read anything from disc
does the page load anything from a database
does the page have any <?php ?> code blocks in it?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-15-2009, 10:38 PM Re: "Date Modified" code is not yielding the proper results
moatist's Avatar
Skilled Talker

Posts: 64
Trades: 0
Heres what I've used in the past for a JavaScript "last updated" script:

Code:
<span style="color:gray";>
  <script language="JavaScript">
  <!-- Begin
  var m = "system updated " + document.lastModified;
  var p = m.length-8;
  document.writeln("<left>");
  document.write(m.substring(p, 0));
  document.writeln("</left>");
  // End -->
  </script>
</span>
Just paste it in place of the other code

-Moatist
__________________
Think in code; Dream in digital.

<?php if($helpfull == true){ $talkupation++; } ?>

Last edited by moatist; 03-15-2009 at 10:40 PM..
moatist is offline
Reply With Quote
View Public Profile
 
Old 03-15-2009, 10:53 PM Re: "Date Modified" code is not yielding the proper results
Novice Talker

Posts: 10
Trades: 0
Actually, it is a PHP file. So, it loads only after I upload it. Here is the code, which can be found in the source at:

http://harry.cckerala.com/90s/download.php

The code which works is in an HTML file, the index page at the above site.

************************************************** **
<p align="center"><font face="Arial, Helvetica, sans-serif" size="-4"><span class="style2"><span class="style5"><span class="style2">Last
modified on
<script type="text/javascript">

var days = new Array(8);

days[1] = "Sunday";

days[2] = "Monday";

days[3] = "Tuesday";

days[4] = "Wednesday";

days[5] = "Thursday";

days[6] = "Friday";

days[7] = "Saturday";

var months = new Array(13);

months[1] = "January";

months[2] = "February";

months[3] = "March";

months[4] = "April";

months[5] = "May";

months[6] = "June";

months[7] = "July";

months[8] = "August";

months[9] = "September";

months[10] = "October";

months[11] = "November";

months[12] = "December";

var dateObj = new Date(document.lastModified)

var wday = days[dateObj.getDay() + 1]

var lmonth = months[dateObj.getMonth() + 1]

var date = dateObj.getDate()

var fyear = dateObj.getYear()

if (fyear < 2000)

fyear = fyear + 1900

document.write(wday + ", " + lmonth + " " + date + ", " + fyear)

</script>
************************************************** **
Thanks.
Harry
Musicollector is offline
Reply With Quote
View Public Profile
 
Old 03-16-2009, 05:40 AM Re: "Date Modified" code is not yielding the proper results
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
IT ISN'T GOING TO WORK ON A SCRIPTED FILE.

scripted files are created there and then by the server, they have a "created date" of "right this very second" and a last modified date of "a fraction of a second ago".

Unless you are going to override those dates with HTTP headers, todays date is what you are going to get.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-16-2009, 01:34 PM Re: "Date Modified" code is not yielding the proper results
moatist's Avatar
Skilled Talker

Posts: 64
Trades: 0
Would this work for you?

PHP Code:
<?
$last_modified 
filemtime("example.php");
print(
"Last Modified ");
print(
date("m/j/y h:i"$last_modified));
?>
__________________
Think in code; Dream in digital.

<?php if($helpfull == true){ $talkupation++; } ?>
moatist is offline
Reply With Quote
View Public Profile
 
Old 03-16-2009, 01:52 PM Re: "Date Modified" code is not yielding the proper results
moatist's Avatar
Skilled Talker

Posts: 64
Trades: 0
I tested the code I posted above and it seems to work.

Here is the modified version of the code above that will show you the exact same thing as what you had before (remember to add styles!):

(paste in place of your JavaScript code)
PHP Code:
<?
$last_modified 
filemtime("download.php");
print(
"Last modified on ");
print(
date("l, F j, o"$last_modified));
?>
-Moatist
__________________
Think in code; Dream in digital.

<?php if($helpfull == true){ $talkupation++; } ?>

Last edited by moatist; 03-16-2009 at 01:54 PM..
moatist is offline
Reply With Quote
View Public Profile
 
Old 03-16-2009, 11:00 PM Re: "Date Modified" code is not yielding the proper results
Novice Talker

Posts: 10
Trades: 0
Hello Moatist,

Thank you very much for the assistance. I have used your first code. Let me try that. However, as it doesn't have time stamps, I won't be able to tell if it works until tomorrow. It seems to be working. I will keep you updated.

Thanks very much again.
Harry
Musicollector is offline
Reply With Quote
View Public Profile
 
Old 03-17-2009, 08:56 PM Re: "Date Modified" code is not yielding the proper results
Novice Talker

Posts: 10
Trades: 0
Okay. The first one did not work. Let me use your second one.

Harry
Musicollector is offline
Reply With Quote
View Public Profile
 
Old 03-17-2009, 11:04 PM Re: "Date Modified" code is not yielding the proper results
moatist's Avatar
Skilled Talker

Posts: 64
Trades: 0
Can you post some more information on how its not working?
__________________
Think in code; Dream in digital.

<?php if($helpfull == true){ $talkupation++; } ?>
moatist is offline
Reply With Quote
View Public Profile
 
Old 03-18-2009, 05:56 PM Re: "Date Modified" code is not yielding the proper results
Novice Talker

Posts: 10
Trades: 0
Thanks again for your kindness in assisting.

Yeah, the most recent one you supplied (the PHP code) doesn't work, either. No problem. I will explain.

As you can see, when you go to: http://harry.cckerala.com/ the "date modified" at the very bottom of the index.html page works perfectly. I modified the page on March 16, 2009 and it stays as is. Hence, it (correctly) says, "Last modified on Monday, March 16, 2009" when myself or anyone else visits the page. My going to the page today does not change the date to March 18, which would be today's date.

Now, the same code at: http://harry.cckerala.com/download.php

gives the message: "Last modified 03/18/2009" when I visit it today. Of course, I have not touched or modified this PHP file any time in the past 2 days! As you know, the nice part here is that you can view the code yourself by viewing the source.

As you can also see, the same thing happens at: http://harry.cckerala.com/90s/download.php where I installed the code you provided.

In effect, the code doesn't produce the desired result as every time any user anywhere at any time loads the page, the date that shows will be the current date - not the date that I modified it on. I hope I am clear.

Thanks again for taking pains.
Harry
Musicollector is offline
Reply With Quote
View Public Profile
 
Old 03-18-2009, 06:02 PM Re: "Date Modified" code is not yielding the proper results
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by Musicollector View Post
In effect, the code doesn't produce the desired result as every time any user anywhere at any time loads the page, the date that shows will be the current date - not the date that I modified it on. I hope I am clear.
So! which bit of this post did you not get?
Quote:
Originally Posted by chrishirst View Post
IT ISN'T GOING TO WORK ON A SCRIPTED FILE.

scripted files are created there and then by the server, they have a "created date" of "right this very second" and a last modified date of "a fraction of a second ago".

Unless you are going to override those dates with HTTP headers, todays date is what you are going to get.
And I'll try and explain it more.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-18-2009, 09:59 PM Re: "Date Modified" code is not yielding the proper results
Novice Talker

Posts: 10
Trades: 0
IT ISN'T GOING TO WORK ON A SCRIPTED FILE?

I did read that part! However, that doesn't explain why it has been working for the past 2-3 years on these same pages with the same script and only stopped working in the past 3 months, or so.

Are you meaning that this will work with HTML files but not with PHP files?

Last edited by Musicollector; 03-18-2009 at 10:00 PM..
Musicollector is offline
Reply With Quote
View Public Profile
 
Old 03-19-2009, 10:42 AM Re: "Date Modified" code is not yielding the proper results
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
It will work perfectly well with .php files as well PROVIDED they have no blocks of code in them.

Files that are parsed by the server will always be served out with the current time and date. Static files, regardless of extension will report the file stats as they are on the disc.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-19-2009, 12:58 PM Re: "Date Modified" code is not yielding the proper results
moatist's Avatar
Skilled Talker

Posts: 64
Trades: 0
I see Chris's point. If you can't seem to find another solution try the following:

1) Create and upload a page named download_date.html. Make sure you put it in the same directory as the download.php page.

2) Add this code to your download.php page:

PHP Code:
<?
$last_modified 
filemtime("download_date.html");
print(
"Last modified on ");
print(
date("l, F j, o"$last_modified));
?>
3) Modify/upload the download_date.html page whenever you modify the download.php page.

4) Repeat steps 1-3 modifying page names accordingly.

I know this is going to a little more trouble, but it should work.

-Moatist
__________________
Think in code; Dream in digital.

<?php if($helpfull == true){ $talkupation++; } ?>

Last edited by moatist; 03-19-2009 at 01:02 PM..
moatist is offline
Reply With Quote
View Public Profile
 
Old 03-19-2009, 11:38 PM Re: "Date Modified" code is not yielding the proper results
Novice Talker

Posts: 10
Trades: 0
THANK YOU, both. I will try your ingenious idea, Moatist. I like it already! I have a hunch that it will work! Will let you know after today.

Also, as I have numerous pages, would placing a "\" after the opening bracket as in: ("\download_date.html") make it look for download_date.html in the server root directory? I don't mind doing it the way you mentioned but I thought I might as well ask, because that will save me some time.

Thanks.

Last edited by Musicollector; 03-19-2009 at 11:41 PM..
Musicollector is offline
Reply With Quote
View Public Profile
 
Old 03-20-2009, 11:44 AM Re: "Date Modified" code is not yielding the proper results
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Or, of course you could simply override the file date with HTTP Headers

PHP Code:
<?php
header
("Last-Modified: Mon, 16 Mar 2009 17:00:00 GMT")
?>
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-20-2009, 01:25 PM Re: "Date Modified" code is not yielding the proper results
Novice Talker

Posts: 10
Trades: 0
Hello Moatist,

It worked!! Thank you for this latest tip, as well. Thanks to both of you for helping. You guys (and this forum) ROCKS!

Harry
Musicollector is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to "Date Modified" code is not yielding the proper results

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.86413 seconds with 12 queries