Day.js :一个轻量的处理时间和日期的 JavaScript 库
作者:互联网
1、封装
import * as dayjs from 'dayjs'
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
export const transformDate = (date, type = 'YYYY-MM-DD') => {
return dayjs.utc(date).format(type)
}
2、引入
import { transformDate } from '@/utils/transform-date'
3、方法
// 时间转化格式
transformDay (time, format) {
return transformDate(time, format)
},
4、使用
<div slot="updated_at" slot-scope="text">
<p>{{transformDay(text,type = 'YYYY.MM.DD')}}</p>
</div>
标签:utc,dayjs,format,轻量,JavaScript,js,transformDate,date,type 来源: https://blog.csdn.net/weixin_41424721/article/details/109584405