formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
// 时间格式化
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(':')
}
使用:
formatTime(new Date())
- 详解JSP 内置对象request常见用法 2019-03-31
- ajax数据返回进行遍历的实例讲解 2019-03-31
- 使用IDEA编写jsp时EL表达式不起作用的问题及解决方法 2019-03-31
- 解决ajax的delete、put方法接收不到参数的问题方法 2019-03-31
- 详细介绍HTTP Cookie 2019-03-31
- SQL 正则表达式及mybatis中使用正则表达式 2019-03-31
- 正则表达式匹配路由的实现代码 2019-03-31
- 通过Ajax请求动态填充页面数据的实例 2019-03-31