用node脚本生成以当天时间-年月日-为名的文件夹
const fs = require('fs');
const path = require('path');
const toTwoDigits = num => num > 9 ? `${num}` : `0${num}`;
function today() {
const date = new Date();
const array = [date.getFullYear(), date.getMonth() + 1, date.getDate()];
return array.map(i => toTwoDigits(i)).join('-');
}
fs.mkdir(path.join(__dirname, today()), () => {
console.log('创建完成');
});
用node脚本生成以当天时间-月日-为名的文件夹
const fs = require('fs');
const path = require('path');
const toTwoDigits = num => num > 9 ? `${num}` : `0${num}`;
function today() {
const date = new Date();
const array = [date.getMonth() + 1, date.getDate()];
return array.map(i => toTwoDigits(i)).join('月')+'日';
}
fs.mkdir(path.join(__dirname, today()), () => {
console.log('创建完成');
});