uni-app——uview将时间戳处理成不同格式的时间格式

简介

接口数据处理的时候经常遇见后台返回的是一个时间戳,怎样将此时间戳处理成自己想要的格式呢?
使用提供的方法的前提是已经安装了uView插件(2.0)。

代码

// 处理时间戳
const timeFormat = uni.$u.timeFormat
this.自定义变量 = timeFormat(时间戳, '时间格式')
// 处理时间戳
const timeFormat = uni.$u.timeFormat
this.update_time = timeFormat(res.data.time, 'yyyy-mm-dd hh:MM')//yyyy-mm-dd hh:MM
//timeFormat(e.value, 'yyyy' + '年' + 'mm' + '月' + 'dd')
//timeFormat(e.value, 'yyyy-mm-dd')

什么样的格式取决于自己怎么写

猜你喜欢

转载自blog.csdn.net/xulihua_75/article/details/126971172