jump to contentsacramento state - leadership begins here  
sac state homeadmissionsabout sac stategiving a giftsite indexcontact us

last reviewed: January 25, 2008

Tutorials - JavaScript Last Updated Date

When you save a file your computer stamps a "last modified" date and time on the file. This script will display the HTML file's last updated date and time.

Step 1

Copy the following JavaScript and paste it into the <body> section of your document where you want the last updated date to appear.

<script language="JavaScript" type="text/javascript">
<!--

var lm = new Date(document.lastModified);

var modifiedYear = lm.getYear();
if(modifiedYear<1000) modifiedYear+=1900;

var last_updated = (lm.getMonth()+1) + '/' + lm.getDate() + '/' + modifiedYear;

document.write(last_updated);

//-->
</script>

Example