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)
	},
相关推荐
阿斌_bingyu7093 小时前
uniapp实现android/IOS消息推送
android·ios·uni-app
茶憶7 小时前
UniApp RenderJS中集成 Leaflet地图,突破APP跨端开发限制
javascript·vue.js·uni-app
2501_9159184119 小时前
移动端 HTTPS 抓包实战,多工具组合分析与高效排查指南
数据库·网络协议·ios·小程序·https·uni-app·iphone
雪芽蓝域zzs1 天前
uni-app 将 base64 图片编码转为 Blob 本地文件路径
网络协议·udp·uni-app
星光一影1 天前
陪诊陪检系统源码,陪诊小程序,陪诊APP,陪诊服务,家政上门系统,居家护理陪护源码
mysql·小程序·uni-app·php
Qlittleboy1 天前
uniapp里 rich-text 里的img图片如何控制最大宽度
uni-app
阿奇__1 天前
uniapp h5 app 小程序获取当前定位
小程序·uni-app
*小雪1 天前
uniapp写H5授权登录及分享,返回到目标页面
开发语言·javascript·uni-app
一只程序熊1 天前
uniapp uniim ios配置消息推送
uni-app
2501_915106321 天前
iOS性能调优的系统化实践,从架构分层到多工具协同的全流程优化指南(开发者深度版)
android·ios·小程序·架构·uni-app·iphone·webview