业务交流通
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12345678910111213141516171819202122
  1. const formatTime = (date,notHour) => {
  2. const year = date.getFullYear()
  3. const month = date.getMonth() + 1
  4. const day = date.getDate()
  5. const hour = date.getHours()
  6. const minute = date.getMinutes()
  7. const second = date.getSeconds()
  8. if(notHour){
  9. return `${[year, month, day].map(formatNumber).join('/')}`
  10. }else{
  11. return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
  12. }
  13. }
  14. const formatNumber = n => {
  15. n = n.toString()
  16. return n[1] ? n : `0${n}`
  17. }
  18. module.exports = {
  19. formatTime
  20. }