utils.js 607 B

123456789101112131415161718192021
  1. // util.js
  2. const formatTime = date => {
  3. const year = date.getFullYear()
  4. const month = date.getMonth() + 1
  5. const day = date.getDate()
  6. const hour = date.getHours()
  7. const minute = date.getMinutes()
  8. const second = date.getSeconds()
  9. return year+"年"+month+"月"+day+"日"
  10. //返回年月日,时分秒
  11. // return [year, month, day].map(formatNumber)//.join(\'/\') + \' \' + [hour, minute].map(formatNumber).join(\':\')
  12. }
  13. // const formatNumber = n => {
  14. // n = n.toString()
  15. // return n[1] ? n : \'0\' + n
  16. // }
  17. module.exports = {
  18. formatTime: formatTime
  19. }