How to Find When a Web Page Was Last Modified

Use this JavaScript command to display a page's last modified date

When you're reading content on the Web, it's often useful to know when that content was last modified to get an idea of whether it may be outdated. When it comes to blogs, most include dates of publication for new content posted. The same is true for many news sites and news articles.

Some pages, however, don't offer a date for when a page was last updated. A date isn't necessary for all pages—some information is evergreen.

But in some cases, knowing the last time a page was updated is important.

Even though a page may not include a "last updated" date, there is a simple command that will tell you this, and it doesn't require you to have a lot of technical knowledge.

To get the date of the last update on a page you're currently, on, simply type the following command into the address bar of your browser and press Enter or click the Go button:

javascript:alert(document.lastModified)

A JavaScript alert window will pop open displaying the last date and time the page was modified.

For users of the Chrome browser and some others, if you cut-and-paste the command into the address bar, be aware that the "javascript:" part is removed. This doesn't mean you can't use the command. You will just need to type that bit back into the command in the address bar.

When the Command Doesn't Work

Technology for web pages changes over time, and in some cases the command to find out when a page was last modified won't work.

For example, it won't work on sites where the page content is generated dynamically. These types of pages are, in effect, being modified with each visit, so this trick doesn't help in these cases.

An Alternative Method: The Internet Archive

Another means of finding when a page was last updated is using the Internet Archive, also known as the "Wayback Machine." In the search field at the top, enter the full address of the web page you want to check, including the "http://" part.

This won't give you a precise date, but you may be able to get an approximate idea of when it was last updated. Note, though, that the calendar view on the Internet Archive site only indicates when the Archive has "crawled" or visited and logged the page, not when the page was updated or modified.

Adding a Last Modified Date to Your Web Page

If you have a webpage of your own, and you would like to show visitors when your page was last updated, you can do this easily by adding some JavaScript code to your page's HTML document.

The code utilizes the same call shown in the previous section: document.lastModified:

 

This will display text on the page in this format:

Last updated on 08/09/2016 12:34:12

You can customize the text preceding the date and time displayed by changing the text between the quotation marks—in the above example, that is the "Last updated " text (note that there is a space after "on" so that the date and time aren't displayed abutting the text).