其他分享
首页 > 其他分享> > 根据时间戳格格式化字符转(dddd-mm-dd )

根据时间戳格格式化字符转(dddd-mm-dd )

作者:互联网

export function getDateTime(value) {
    var b = new Date(value);
    var year = b.getFullYear()+'-';
    var month = (b.getMonth()+1);
    var date = b.getDate();
    if(month<10){
        month = '0'+ (b.getMonth()+1)+'-';
    }else {
        month = (b.getMonth()+1)+'-';
    }
    if(date<10){
        date = '0'+ (b.getDate());
    }
    var str = String(year)+String(month)+String(date)+ ' ';
    return str;
}

// 使用
import {getDateTime} from "@/utils/utils.js"
getDateTime(date);  // 2022-07-20 

标签:function,戳格,mm,dd,getFullYear,value,month,var
来源: https://www.cnblogs.com/rzl795/p/16586141.html