Click to See Complete Forum and Search --> : Display the Last modified date of a page!!


dianazheng
September 26th, 2004, 08:12 AM
Hi
Can anyone tell me, how can display just the last modified date of a page.
I just wanted the date, this date is taken from the system, and the date should display like eg september, 26, 2004 .

Thanks in advance

diana

Mark Agius
September 26th, 2004, 05:32 PM
You can use the following code;

<SCRIPT LANGUAGE="JavaScript">
<!--
document.write("This page was saved on; ");

var PageDate = this.document.lastModified;

document.write( PageDate +"<BR>\n");
//-- End of JavaScript code -->
</SCRIPT>


The problem with this code is that it returns the date and time as a string.

Eg. Netscape Navigator will return Sunday, September 26, 2004 21:51:52
and Internet Explorer will return 09/26/2004 21:51:52

So you will need to check if they are using Netscape or Explorer with;

if (document.all) { IE_code=true }
if (document.layers){ NS_code=true }

Then read the string and convert it to '26/09/2004 - 9:51:52pm'
(The International date standatd and not the US format of 09-26-2004)
(Today is the 9th of Feburary, 2006! (9/02/2004 + 24 months))

dianazheng
September 28th, 2004, 11:30 PM
i get my code working already, thank for your help.