tool.js 527 B

1234567891011121314151617
  1. export function dateFormmat(date) {
  2. const T = date ? new Date(date) : new Date();
  3. const P = {
  4. year: T.getFullYear(),
  5. month: T.getMonth() - 0 + 1,
  6. day: T.getDate(),
  7. hour: T.getHours(),
  8. min: T.getMinutes(),
  9. s: T.getSeconds()
  10. }
  11. P.month > 9 ? P.month = P.month : P.month = "0" + P.month;
  12. P.day > 9 ? P.day = P.day : P.day = "0" + P.day;
  13. P.hour > 9 ? P.hour = P.hour : P.hour = "0" + P.hour;
  14. P.min > 9 ? P.min = P.min : P.min = "0" + P.min;
  15. P.s > 9 ? P.s = P.s : P.s = "0" + P.s;
  16. return P
  17. }