使用 moment.js 库在 Node.js 中获取时间的各种格式非常简单。首先需要在项目中安装 moment 库,然后在代码中引入它,如下所示: const moment = require('moment');