SOURCE

function format(date, fmt) {
    var myDate = new Date(date);
    var o = {
        "M+": myDate.getMonth() + 1, //月份 
        "d+": myDate.getDate(), //日 
        "h+": myDate.getHours(), //小时 
        "m+": myDate.getMinutes(), //分 
        "s+": myDate.getSeconds(), //秒 
        "q+": Math.floor((myDate.getMonth() + 3) / 3), //季度 
        "S": myDate.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (myDate.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        }
    }
    return fmt;
}
console.log(new Date(new Date().getTime() - 24 * 60 * 60 * 1000))
console.log(format( new Date(new Date().getTime() - 24 * 60 * 60 * 1000), 'yyyy-MM-dd hh:mm:ss')); // 09:11:31
console 命令行工具 X clear

                    
>
console