Skip to content

day 日期时间 dayjs

函数名描述类型参数返回值
dateFormat时间格式化(val:<string | number | Date>)=> string(date:要转换的时间, format: 转换成那种格式 默认YYYY-MM-DD HH-mm-ss)String
dayjsdayjs文档

示例

日期时间转换例子
函数名例子返回值
dateFormatdateFormat(new Date())2024-12-25 17:09:24
dateFormatdateFormat("2024-10-1")2024-10-01 00:00:00
dateFormatdateFormat("2024-10-1 8:8:8", "YYYY-MM-DD")2024-10-01
dateFormatdateFormat("2024-10-1 8:8:8", "YYYY-MM-DD hh-mm")2024-10-01 08-08
dateFormatdateFormat(1722654892315)2024-08-03 11:14:52

<template>
  <div>
    <config-table title="日期时间转换例子" :list="list"></config-table>
  </div>
</template>

<script setup lang="ts">
  import { dateFormat } from '@vtj/utils';

  import ConfigTable from '$/components/configTable.vue';

  const list = [
    {
      name: 'dateFormat',
      example: 'dateFormat(new Date())',
      return: dateFormat(new Date())
    },
    {
      name: 'dateFormat',
      example: 'dateFormat("2024-10-1")',
      return: dateFormat('2024-10-1')
    },
    {
      name: 'dateFormat',
      example: 'dateFormat("2024-10-1 8:8:8",  "YYYY-MM-DD")',
      return: dateFormat('2024-10-1 8:8:8', 'YYYY-MM-DD')
    },
    {
      name: 'dateFormat',
      example: 'dateFormat("2024-10-1 8:8:8",  "YYYY-MM-DD hh-mm")',
      return: dateFormat('2024-10-1 8:8:8', 'YYYY-MM-DD hh-mm')
    },
    {
      name: 'dateFormat',
      example: 'dateFormat(1722654892315)',
      return: dateFormat(1722654892315)
    }
  ];
</script>

Released under the MIT License.