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)
	},
相关推荐
小徐_233315 小时前
uni-app vue3 也能使用 Echarts?Wot Starter 是这样做的!
前端·uni-app·echarts
iOS阿玮20 小时前
永远不要站在用户的对立面,挑战大众的公知。
uni-app·app·apple
xw521 小时前
uni-app中v-if使用”异常”
前端·uni-app
!win !21 小时前
uni-app中v-if使用”异常”
前端·uni-app
2501_915918411 天前
iOS 上架全流程指南 iOS 应用发布步骤、App Store 上架流程、uni-app 打包上传 ipa 与审核实战经验分享
android·ios·小程序·uni-app·cocoa·iphone·webview
00后程序员张1 天前
iOS App 混淆与加固对比 源码混淆与ipa文件混淆的区别、iOS代码保护与应用安全场景最佳实践
android·安全·ios·小程序·uni-app·iphone·webview
00后程序员张2 天前
详细解析苹果iOS应用上架到App Store的完整步骤与指南
android·ios·小程序·https·uni-app·iphone·webview
海绵宝宝不喜欢侬2 天前
uniapp-微信小程序分享功能-onShareAppMessage
微信小程序·小程序·uni-app
2501_915106322 天前
Xcode 上传 ipa 全流程详解 App Store 上架流程、uni-app 生成 ipa 文件上传与审核指南
android·macos·ios·小程序·uni-app·iphone·xcode
xkxnq2 天前
Uniapp崩溃监控体系构建:内存泄漏三维定位法(堆栈/资源/线程)
uni-app