/    Sign up×
Community /Pin to ProfileBookmark

date page last updated

I have taken the script used on another page of mine:
[url]http://www.hml.noaa.gov[/url]
that shows the date when the page is last updated, and applied it to this page:
[url]http://www.cofc.edu/~grice[/url]
but what is displaying is the current date, NOT the date of the last update.

So, could this possibly be some sort of server problem? The pages are hosted on different servers.

[code]<script type=”text/javascript”><!–//–><![CDATA[//><!–
document.write( “<br>Last updated “+ wday + “, ” + lmonth + ” ” + date + “, ” + fyear + “.”)
//–><!]]></script>[/code]

[code] <script type=”text/javascript”><!–//–><![CDATA[//><!–
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
//–><!]]></script>[/code]

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@CharlesJul 15.2006 — You'll get that. document.lastModified reads the modification date off of the HTTP response header but not all servers send that header. It looks like that second server is one of those.

Oh, and that script you are using is pretty bad. I wouldn't use it at all.
Copy linkTweet thisAlerts:
@netbuddyJul 15.2006 — We all start somewhere and I would suggest that you try here to improve your code skills... http://www.htmlgoodies.com/
Copy linkTweet thisAlerts:
@quartneyauthorJul 15.2006 — Okay, I understand why .lastmodified doesn't work, but do you have a suggestion of another way to make a "page last updated" statement, automatically?

Thanks!
Copy linkTweet thisAlerts:
@CharlesJul 15.2006 — We all start somewhere and I would suggest that you try here to improve your code skills... http://www.htmlgoodies.com/[/QUOTE]Do not, even to save you own life, go to the HTML Goodies site. It's the worst that's out there.
Copy linkTweet thisAlerts:
@CharlesJul 15.2006 — Okay, I understand why .lastmodified doesn't work, but do you have a suggestion of another way to make a "page last updated" statement, automatically?

Thanks![/QUOTE]
The simpliest is still the best. Just type one.

Or you could do this server side. Do you have SSI or PHP available.
Copy linkTweet thisAlerts:
@quartneyauthorJul 15.2006 — I found a way to do it in Dreamweaver.
Copy linkTweet thisAlerts:
@netbuddyJul 15.2006 — Do not, even to save you own life, go to the HTML Goodies site. It's the worst that's out there.[/QUOTE]

I would say that your opinion is your own, I however did not pull you up on your inital comment to the poster to 'not bother using' the script... which incidentally is 'out of order' on your part as it was not called for.

My suggestion was a valid one, it helps allot of people and IM sure that this forum could help this person to script better, your suggestion does not really count as help, mine would.

So zip ya mush, mush.
Copy linkTweet thisAlerts:
@CharlesJul 15.2006 — It is certainly not out of order to point out that some script is badly written - and that one is so bad and out of date that it will give you the wrong year for certain browsers.

And it is certainly the fact that HTML Goodies contains a great many errors and omissions - I really have seen none worse. Go there and you'll learn a bunch of stuff that you'll just have to unlearn later.
Copy linkTweet thisAlerts:
@netbuddyJul 15.2006 — Get back in ya pram m8.
Copy linkTweet thisAlerts:
@jalarieJul 17.2006 — When the server doesn't send a document.lastModified value, different browsers do different things.

Internet Explorer uses the null value as-is in the Date() function and gets the current date and time. This makes your users think that you've just updated the page and you look great. Once they realize that it's just junk information, you don't look so great at all!

Netscape forces the null to be numeric, gets a zero at this point, uses the zero in the Date() function, and gets the first midnight of January 1st, 1970, and then adjusts for timezone offset. For me, in the eastern United States, this displays as 7:00pm on December 31st, 1969.

WebTV is much like Netscape, but does the timezone offset earlier. For people in the western hemisphere, this produces a negative value going into the Date() function, and it objects.

Every other browser that I've tried follows one of these three patterns.

If you want to be sure of getting a reasonable result, type it in directly.
×

Success!

Help @quartney spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...