dates.js 305 B

12345678910
  1. export const dateFormat = (date, format = 'yyyy-MM-dd') => {
  2. const year = date.getFullYear()
  3. const month = date.getMonth() + 1
  4. const day = date.getDate()
  5. return format.replace('yyyy', year)
  6. .replace('MM', (month < 10 ? '0' + month : month))
  7. .replace('dd', (day < 10 ? '0' + day : day))
  8. }