获取几天前几天后的时间并格式化

获取当前时间
let now = new Date();
获取三天前时间
    let threeNow = new Date(now.getTime() - 24*60*60*1000*3);
时间格式化
    let nowStr = now.format("yyyy-MM-dd hh:mm:ss");
    let threeStr = threeNow.format(`yyyy-MM-dd hh:mm:ss`);

 

posted @ 2020-03-24 11:31  无人问及  阅读(194)  评论(0编辑  收藏  举报