首页 > Web开发 > 详细

ES 6 日期util.js =>

时间:2018-01-19 10:35:31      阅读:358      评论:0      收藏:0      [点我收藏+]

微信小程序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 =>

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!