js数字时钟

来源:百度知道 编辑:UC知道 时间:2024/06/05 16:05:52
js数字时钟

<span id="datetime">time</span>
<script>
function setTime(){
var day="";
var month="";
var ampm="";
var ampmhour="";
var myweekday="";
var year="";
var myHours="";
var myMinutes="";
var mySeconds="";
mydate=new Date();
myweekday=mydate.getDay();
mymonth=parseInt(mydate.getMonth()+1)<10?"0"+(mydate.getMonth()+1):mydate.getMonth()+1;
myday= mydate.getDate();
myyear= mydate.getYear();
myHours = mydate.getHours();
myMinutes = mydate.getMinutes();
mySeconds = parseInt(mydate.getSeconds())<10?"0"+mydate.getSeconds():mydate.getSeconds();
year=(myyear > 200) ? myyear : 1900 + myyear;
if(myweekday == 0)
weekday=" 星期日 ";