Một tài liệu trải qua nhiều thay đổi. JavaScript cung cấp document.lastModified lấy thời điểm sửa đổi cuối. Trả về ngày giờ chính xác.
Cú pháp
Time = document.lastModified;
Ví dụ 1
Dùng document.lastModified hiển thị ngày giờ sửa đổi cuối.
<html> <body> <script> document.write("This document is lastly modified on" + " " + document.lastModified); </script> </body> </html>
Kết quả
This document is lastly modified on 07/29/2019 15:19:41
Ví dụ 2
Dùng document.lastModified hiển thị trong span.
<html> <body> <p>This document was last modified <span id="modify"></span>.</p> <script> document.getElementById("modify").innerHTML = document.lastModified </script> </body> </html>
Kết quả
This document was last modified 07/29/2019 15:26:23.