Date and Error
Build timestamps with Date, and report failures with Error + try/catch.
Date constructor
Date details appear here.
Error constructor
Throw a new Error when input is empty. Catch it and show the message.
Important JavaScript
const now = new Date();
now.getFullYear();
now.toISOString();
const stamped = new Date("2026-09-11T09:00:00");
try {
if (!text) {
throw new Error("Note is required.");
}
} catch (error) {
status.textContent = error.message;
}