精简版本、适用于 weex 应用的 moment 库,用于日期处理,提供日期解析、格式化等方便的工具类。
// 该组件不在 nuke 大包中,需要单独安装依赖
// 切换到你的项目中
npm install nuke-biz-moment --save
// 打开工程文件
import moment from 'nuke-biz-moment';
console.log(moment().format('YYYY/MM/DD'))
// 按照指定格式格式化
moment('2017/5/22').format('YYYY/MM/DD hh:mm:ss') // 2017/08/17 13:52:43
moment('2017/5/22').year()
moment('2017/5/22').month()
moment('2017/5/22').date()
moment('2017/5/22').second()
moment('2017/5/22').minute()
moment('2017/5/22').format()
moment('2017/35/22').isValid() // false
moment('2017/10/20').isAfter('2017/10/19'); // true
// 减几天
moment('2017/07/22').addDay(-2).format('YYYY/MM/DD')} // 2017-07-20
// 月份有多少天
moment("2012/02", "YYYY/MM").daysInMonth() //29