太勾八难找了。做个备份

//1. 时间转时间戳:
//当前时间
 Date.parse(new Date()); 
//任意时间
 Date.parse(new Date('2023-01-01')); 
//2. 时间戳转时间
//不需要时分秒就把后面的部分删了
function getDateByTimestamp() {
            var now = new Date(),
                y = now.getFullYear(),
                m = now.getMonth() + 1,
                d = now.getDate();
            return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) 
+ " " + now.toTimeString().substr(0, 8);
        }
最后修改:2023 年 08 月 26 日
感恩的心,感谢有你!