码迷,mamicode.com
首页 > Web开发 > 详细

ES 6 日期util.js =>

时间:2018-01-19 11:35:53      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:程序   second   return   eth   post   tostring   exports   小程序   blog   

微信小程序demo

const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()

return [year, month, day].map(formatNumber).join(‘/‘) + ‘ ‘ + [hour, minute, second].map(formatNumber).join(‘:‘)
}

const formatNumber = n => {
n = n.toString()
return n[1] ? n : ‘0‘ + n
}

module.exports = {
formatTime: formatTime
}

ES 6 日期util.js =>

标签:程序   second   return   eth   post   tostring   exports   小程序   blog   

原文地址:https://www.cnblogs.com/humi/p/8314056.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!