uniapp时间戳转时间

时间戳转时间

utils页面

javascript 复制代码
function timestampToTime(time) {  
    const date = new Date(time);  
    const year = date.getFullYear();  
    const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以要加1,并补齐0  
    const day = String(date.getDate()).padStart(2, '0'); // 补齐日期  
    const hours = String(date.getHours()).padStart(2, '0'); // 补齐小时  
    const minutes = String(date.getMinutes()).padStart(2, '0'); // 补齐分钟  
    const seconds = String(date.getSeconds()).padStart(2, '0'); // 补齐秒  
    const convertedTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;  
    return convertedTime;  
}

使用页面

javascript 复制代码
<view class="content" v-for="item in refuelList" :key="item.id" @click="detail(item.id)">
	<view class="payTime">
		{{dataFormat(item.tranTime)||'-'}}
	</view>
</view>
// 时间戳转时间
	dataFormat(time) {
		if (!time) {
			return null
		}
		return this.$utils.timestampToTime(time)
	},
相关推荐
2501_9160074720 分钟前
iOS 自动化上架的工具组合,在多平台环境中实现稳定发布
android·运维·ios·小程序·uni-app·自动化·iphone
1024小神21 分钟前
uniapp项目中使用vue3和小程序组件父子通信
前端·小程序·uni-app
fruge2 小时前
华玥组件库 · 为 uni-app 打造的新一代高效组件解决方案
uni-app
遗憾随她而去.15 小时前
uniapp 折叠动画 <transition> 踩坑记录
css·uni-app
百锦再21 小时前
Elements Plus 跨设备自适应显示问题综合解决方案
python·flutter·小程序·uni-app·k8s·tornado·net
坚持学习前端日记1 天前
UniApp APK打包与Android深度集成能力解析
android·vue.js·uni-app
wetyuo2 天前
【随手记】uniapp + V3 使用TailwindCss3
uni-app·vue·css3·vite
小恒恒4 天前
2025 Vibe Coding 有感
前端·uni-app·trae
一颗小青松4 天前
uniapp使用uni-im
uni-app
2501_916007474 天前
iPhone APP 性能测试怎么做,除了Instruments还有什么工具?
android·ios·小程序·https·uni-app·iphone·webview