JavaScript Date setMinutes ()
ví dụ 1
Đặt phút thành 17:
const d = new Date();
d.setMinutes(17);
Định nghĩa và Cách sử dụng
setMinutes()
thiết lập các phút của một ngày.
Phương pháp này cũng có thể được sử dụng để đặt giây và mili giây.
Ví dụ 2
Đặt ngày giờ là 90 phút trước :
const d = new Date();
d.setMinutes(d.getMinutes() - 90);
Hỗ trợ trình duyệt
setMinutes()
là một tính năng ECMAScript1 (ES1).
ES1 (JavaScript 1997) được hỗ trợ đầy đủ trong tất cả các trình duyệt:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
Cú pháp
Date.setMinutes(min, sec, millisec)
Giá trị tham số
Parameter | Description |
---|---|
min | Required. An integer representing the minutes.
Expected values are 0-59, but other values are allowed:
|
sec | Optional. An integer representing the seconds
Expected values are 0-59, but other values are allowed:
|
millisec | Optional. An integer representing the milliseconds
Expected values are 0-999, but other values are allowed:
|
Chi tiết kỹ thuật
Giá trị trả lại: | Một Số, đại diện cho số mili giây giữa đối tượng ngày tháng và nửa đêm ngày 1 tháng 1 năm 1970 |
---|---|
Phiên bản JavaScript: | ECMAScript 1 |