Transforming lastModified into a Date object

Transforming lastModified into milliseconds

This example transforms lastModified into the number of milliseconds since January 1, 1970, 00:00:00, local time.

let nLastModif = Date.parse(document.lastModified);

Notes

Note that as a string, lastModified cannot easily be used for comparing the modification dates of documents. Here is a possible example of how to show an alert message when the page changes (see also: JavaScript cookies API):