1, substantially in the vue
- installation
npm install moment --save
- Introduced
import moment from 'moment'
Moment () which can transmit time may be the time does not pass, do not pass the time representing the current time
- format
moment().format('YYYY-MM-DD HH:mm:ss') //当前时间2019-11-11 19:34:50
moment('2012-1-2 1:1:2').format('YYYY-MM-DD HH:mm:ss') //2012-01-02 01:01:02
- The day before or a day after acquisition time
moment('2019-10-10').add(-1,'days').format('YYYY-MM-DD') //获取时间前一天
moment('2019-10-10').add(1,'days').format('YYYY-MM-DD') //获取时间后一天,后面的format是格式化时间
- Gets week
moment('2019-11-11').format('d') //0 获取星期几,星期天为0
- Acquires a time stamp
moment().format('X') //1573472326