多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
757 B

2 years ago
  1. /**
  2. * @FileDescription:
  3. * @Author: kahu
  4. * @Date: 2022/11/7
  5. * @LastEditors: kahu
  6. * @LastEditTime: 2022/11/7
  7. */
  8. /**
  9. * 时间格式化
  10. * @param endTimeStamp
  11. * @constructor
  12. */
  13. export const TimeFormatting = (timeDifference)=>{
  14. // 天数
  15. let day = Math.floor(timeDifference / 3600 / 24);
  16. // 小时
  17. let hr = Math.floor(timeDifference / 3600 % 24);
  18. // 分钟
  19. let min = Math.floor(timeDifference / 60 % 60);
  20. // 秒
  21. let sec = Math.floor(timeDifference % 60);
  22. return {
  23. day : timeFormat(day),
  24. hour: timeFormat(hr),
  25. min : timeFormat(min),
  26. sec : timeFormat(sec)
  27. }
  28. }
  29. //时分秒换算
  30. function timeFormat(param) { //小于10的格式化函数
  31. return param < 10 ? '0' + param : param;
  32. }