Blame view

mini-program-test/utils/util.js 460 Bytes
8dbd6143   YunaiV   增加微信小程序的登陆的测试代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  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
  }