代码github地址:https://github.com/haozhaohang/library
作者: 易怜白
项目中使用了时间日期的处理方法,只使用了部分方法,为了不在引入第三方的库(moment.js),这里自己封装了项目中使用到的方法。
要实现以下功能:
new Moment() // 返回当前的时间对象 new Moment().unix() // 返回当前时间的秒数 Moment.unix(timestamp) // 传入秒数,返回传入秒数的时间对象 new Moment().format('YYYY-MM-DD dd HH:mm:ss') // 返回值 2017-06-22 四 19:46:14 Moment.unix(1498132062000).format('YYYY-MM-DD dd HH:mm:ss') // 返回值 2017-06-22 四 19:46:14