JS 日期加减

下面是月份加六个月例子:
var date = new Date();//获取当前日期
console.log(date.toLocaleDateString());//转换并打印 yyyy/mm/dd 日期显示格式 
date.setMonth(date.getMonth()+6);//当前月份加六个月
console.log(date.toLocaleDateString());
控制台运行截图:
JS 日期加减_第1张图片
image.png

你可能感兴趣的:(JS 日期加减)