<script type="text/javascript">
function getNow(Mytime) { return Mytime < 10 ? '0' + Mytime : Mytime; }
function CurrentTime() {
var myDate = new Date();
//获取当前年份
var year = myDate.getFullYear();
//获取当前月份
var month = myDate.getMonth() + 1;
//获取当前日期
var date = myDate.getDate();
//获取当前小时数(0-23)
var h = myDate.getHours();
//获取当前分钟数(0-59)
var m = myDate.getMinutes();
var s = myDate.getSeconds();
var now = year + '-' + getNow(month) + "-" + getNow(date) + " " + getNow(h) + ':' + getNow(m) + ":" + getNow(s);
$("#time1").text(now);
}
//间隔一秒执行一次获取当前时间的方法
setInterval(function () { CurrentTime() }, 1000);
</script>