js获取某一天的日期

2021年1月25日 150点热度 0人点赞 0条评论
    const nowTime = new Date("2000-01-22").getTime()
    const nowDate = new Date(nowTime + 13 * 24 * 60 * 60 * 1000);
    nowDate.setMonth(nowDate.getMonth());
    var date = new Date(nowDate)
    var y = date.getFullYear()
    var m = date.getMonth() + 1
    m = m < 10 ? ('0' + m) : m;
    var d = date.getDate()
    d = d < 10 ? ('0' + d) : d;
    var h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    var min = date.getMinutes();
    min = min < 10 ? ("0" + min) : min;
    var s = date.getSeconds();
    s = s < 10 ? ("0" + s) : s;
    const time = y + '年' + m + '月' + d + "日";

 

读心悦

读心,读自己!