formatDate.js 458 Bytes
// 反斜杠转文字,type= -1:年月日,0:月日,1:日
const slashToString = (date, type = -1) => {
    let newDate = '';
    let dateString = ['年', '月', '日'];

    date.split('/').forEach((val, index) => {
        if (index <= type) {
            return;
        } else {
            newDate = newDate + date.split('/')[index] + dateString[index];
        }
    });

    return newDate;
};

module.exports = {
    slashToString: slashToString
};