在 JavaScript 中获取当前时间共有以下步骤:创建 Date 对象:const now = new Date();使用属性和方法获取具体时间信息,如:now.toDateString():获取完整日期字符串now.toLocaleDateString():获取本地化日期字符串now.toTimeString():获取完整时间字符串now.toLocaleTimeString():获取本地化时间字符串now.toISOString():获取 ISO 8601 格式日期和时间字符串now.g