converter.js 245 B

123456789
  1. export const convertDate = (t) => {
  2. if (typeof t === 'number') {
  3. t = String(t).length === 13 ? t : t * 1000;
  4. }
  5. else if (typeof t === 'string') {
  6. t = t.replace(/\s+/g, 'T') + '+08:00';
  7. }
  8. return new Date(t);
  9. };