util.js 667 B

1234567891011121314151617181920212223242526272829
  1. const formatTime = date => {
  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. return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
  9. }
  10. const formatNumber = n => {
  11. n = n.toString()
  12. return n[1] ? n : '0' + n
  13. }
  14. const isPoneAvailable= phone => {
  15. var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
  16. if (!myreg.test(phone)) {
  17. return false;
  18. } else {
  19. return true;
  20. }
  21. }
  22. module.exports = {
  23. formatTime: formatTime,
  24. isPoneAvailable: isPoneAvailable
  25. }