时间戳转换年月日

2018-10-12  本文已影响0人  yiqian091

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;//时分秒可以根据自己的需求加上

}

上一篇下一篇

猜你喜欢

热点阅读