Thuộc tính dateTime của đối tượng ins trong HTML DOM trả về ngày và giờ khi văn bản được chèn vào.
Cú pháp
Trả về giá trị chuỗi:
insObject.dateTime
Ví dụ
Ví dụ minh họa thuộc tính ins dateTime:
<!DOCTYPE html> <html> <head> <title>ins dateTime</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } </style> </head> <body> <form> <fieldset> <legend>ins-dateTime</legend> <h1>Thực tế:</h1> <p>Nước không thể tồn tại trên bề mặt Mặt Trăng. <ins id="newInfo" cite="https://www.example.com/water-ice-moon-surface-confirmed.html" datetime="2018-08-21T18:23Z"> Đã tìm thấy băng nước trên Mặt Trăng.</ins> </p> <input type="button" onclick="getDate()" value="Thay đổi này được thực hiện khi nào?"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var insDateTime = document.getElementById("newInfo"); function getDate() { divDisplay.textContent = 'Text inserted on '+insDateTime.dateTime.split("T")[0]; divDisplay.textContent += ' at '+insDateTime.dateTime.split("T")[1]; } </script> </body> </html>
Kết quả
Trước khi nhấn nút 'Thay đổi này được thực hiện khi nào?':

Sau khi nhấn nút 'Thay đổi này được thực hiện khi nào?':
