Notification: thuộc tính timestamp

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Note: This feature is available in Web Workers.

Thuộc tính chỉ đọc timestamp của giao diện Notification trả về một số, như được chỉ định trong tùy chọn timestamp của constructor Notification().

Dấu thời gian của thông báo có thể biểu thị thời điểm, tính bằng mili giây kể từ 00:00:00 UTC ngày 1 tháng 1 năm 1970, của sự kiện mà thông báo được tạo ra, hoặc có thể là một dấu thời gian tùy ý mà bạn muốn gắn với thông báo. Ví dụ, dấu thời gian của một cuộc họp sắp tới có thể được đặt trong tương lai, trong khi dấu thời gian của một tin nhắn bị lỡ có thể được đặt trong quá khứ.

Giá trị

Một số đại diện cho dấu thời gian, được cho dưới dạng Unix time tính bằng mili giây.

Ví dụ

Đoạn mã sau phát một thông báo; một object options đơn giản được tạo rồi thông báo được phát bằng constructor Notification().

js
const dts = Math.floor(Date.now());

const options = {
  body: "Your code submission has received 3 new review comments.",
  timestamp: dts,
};

const n = new Notification("New review activity", options);

console.log(n.timestamp); // Ghi lại dấu thời gian

Thông số kỹ thuật

Specification
Notifications API
# dom-notification-timestamp

Tương thích trình duyệt

Xem thêm