SOURCE

console 命令行工具 X clear

                    
>
console
$(function(){
  $("#input").keyup(function(){
    var time = $("#input").val();

    var format = $("#input1").val();
    $("#temp2").html(checkDate(time, format));
  
  });
})
//时间格式化
function checkDate(date, geshi) {
    var dategehsi = 'MM/dd/yyyy hh:mm:ss'
    if (geshi != null) {
        dategehsi = geshi;
    }
    return new Date(date).format(dategehsi);
}

Date.prototype.format = function (format) {
    var o = {
        "M+": this.getMonth() + 1, //month
        "d+": this.getDate(),    //day
        "h+": this.getHours(),   //hour
        "m+": this.getMinutes(), //minute
        "s+": this.getSeconds(), //second
        "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
        "S": this.getMilliseconds() //millisecond
    }
    if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
        (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)if (new RegExp("(" + k + ")").test(format))
        format = format.replace(RegExp.$1,
            RegExp.$1.length == 1 ? o[k] :
                ("00" + o[k]).substr(("" + o[k]).length));
    return format;
}
<label>时间:</label>
<input id="input">  
<label>格式:</label>
<input id="input1" value="yyyy/MM/dd">
<br><br>
<label>结果:</label>
<p id="temp2"></p>

本项目引用的自定义外部资源