其他分享
首页 > 其他分享> > uniapp将时间日期格式化的组件uni-dateformat的用法

uniapp将时间日期格式化的组件uni-dateformat的用法

作者:互联网

uniapp开发时,我们需要将数据库里取到的时间戳格式化为某个格式的日期时间形式,uniapp官方插件市场的uni-dateformat组件即可解决。

 

uniapp官方插件地址及详细用法介绍:https://ext.dcloud.net.cn/plugin?id=3279

 

刚开始用时,显示日期时间为1970年,只要给数据库里的值乘以1000即可,

 

如,我们从数据库取到的时间戳变量为:rs.addtime,在template模板里直接用就行了,无须注册等,代码如下:

<!-- 从数据库取到的时间戳变量为:rs.addtime -->
<uni-dateformat :date="rs.addtime*1000" format="yyyy/MM/dd"></uni-dateformat>

 

标签:uniapp,插件,dateformat,数据库,取到,uni
来源: https://www.cnblogs.com/lazb/p/15563794.html