日期类
Posted haishen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了日期类相关的知识,希望对你有一定的参考价值。
1、将时间戳转换成 2018-12-13 17:35:26
function changeDate(time){ if(!!time){ let getTime = parseInt(time) * 1000; let date = new Date(getTime); let year = date.getFullYear(); let month = parseInt(date.getMonth()) + 1; if(month < 10){ month = "0" + month; } let day = date.getDate(); if(day < 10){ day = "0" + day; } let hours = date.getHours(); if(hours < 10){ hours = "0" + hours; } let minutes = date.getMinutes(); if(minutes < 10){ minutes = "0" + minutes; } let seconds = date.getSeconds(); if(seconds < 10){ seconds = "0" + seconds; } return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds; }else{ return ‘‘; } }
以上是关于日期类的主要内容,如果未能解决你的问题,请参考以下文章
sql 日期转换代码片段 - Dato,120,konvertere
Android Navigation java.language.IllegalStateException 片段类未设置