管灌系统农户端微信小程序(嘉峪关应用)
zuoxiao
2025-04-07 5d3ed12a593020ec7fd9b5af50991f68b191e649
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
}