【英文】Nodejs的moment模块学习笔记

Introduction

Formatting time and date using the moment module in Node.js.

Download Dependencies

1
npm install moment

Time and Date Formatting

  • Use the moment() function to get the current time.
  • Use the format() function to format the time.
1
2
3
const moment = require("moment");

let time = moment().format("YYYY-MM-DD HH:mm:ss");

Conclusion

References

Bilibili - Black Horse Programmer