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>

 

相关文章:

  • 2021-08-24
  • 2022-12-23
  • 2022-02-16
  • 2022-02-14
  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-08
  • 2022-12-23
  • 2021-04-02
  • 2021-12-10
  • 2021-07-18
  • 2021-10-08
  • 2021-07-30
相关资源
相似解决方案