美文网首页
时间戳转换年月日

时间戳转换年月日

作者: yiqian091 | 来源:发表于2018-10-12 11:07 被阅读0次

    function timestampToTime(timestamp) {

    var date =new Date(timestamp);//时间戳为10位需*1000,时间戳为13位的话不需乘1000

        Y = date.getFullYear() +'年';

        M = (date.getMonth() +1 <10 ?'0' + (date.getMonth() +1) : date.getMonth() +1) +'月';

        D = date.getDate() +'日';

        h = date.getHours() +':';

        m = date.getMinutes() +':';

        s = date.getSeconds();

        return Y +M +D;//时分秒可以根据自己的需求加上

    }

    相关文章

      网友评论

          本文标题:时间戳转换年月日

          本文链接:https://www.haomeiwen.com/subject/cjmogftx.html