📅  最后修改于: 2023-12-03 15:16:04.951000             🧑  作者: Mango
getMinutes()
方法是 JavaScript 中 Date()
对象的一个方法,用于获取指定日期对象的分钟数。返回值是一个整数,范围为 0 到 59。
date.getMinutes()
该方法没有参数。
返回指定日期对象的分钟数,范围为 0 到 59。
const now = new Date();
const minutes = now.getMinutes();
console.log(minutes); // 输出当前时间的分钟数
01
。getMinutes()
方法的替代方法 getUTCMinutes()
。const now = new Date();
const minutes = (now.getMinutes() < 10 ? '0' : '') + now.getMinutes();
console.log(minutes); // 输出当前时间的分钟数,并在其前面加上可能的前导零