Skip to content

useFormatDate(日期格式化)

ts
import { useFormatDate } from 'velo-kit'
import type { useFormatDateOptions } from 'velo-kit'

const options: useFormatDateOptions = {
  dateString: new Date('2024-02-27 12:34:56'),
  format: 'YYYY-MM-DD HH-mm-ss',
  chinese: true,
}

const result = useFormatDate(options)
// '2024年02月27日12时34分56秒'

options参数

参数说明类型默认值
dateString日期Date-
format格式化string'YYYY-MM-DD HH:mm:ss'
chinese是否中文booleanfalse
symbol分隔符string-
add0是否添加0booleantrue

MIT Licensed