<div class="time"> <dl> <dd> UTC时间 <span id="UTCTime">HH:MM:SS</span></dd> <dd> 北京时间 <span id="BJTime">HH:MM:SS</span></dd><div class="clear"> </div> </dl> </div> <script type="text/javascript"> $(document).ready(function () { setInterval(function () { fnDate(); }, 1000); }); function fnDate() { var date = new Date(); var hours = date.getHours(); //小时 var minute = date.getMinutes(); //分 var second = date.getSeconds(); //秒 var time = fnW(hours) + ": " + fnW(minute) + ": " + fnW(second); $("#BJTime").html(time); var UTChours = date.getUTCHours(); var UTCminute = date.getUTCMinutes(); var UTCsecond = date.getUTCSeconds(); time = fnW(UTChours) + ": " + fnW(UTCminute) + ": " + fnW(UTCsecond); $("#UTCTime").html(time); }; function fnW(str) { var num; str >= 10 ? num = str : num = "0" + str; return num; } </script>