1<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">234<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>5<title> make 12-hour clock </title>6<script type= "Text/javascript" >7 8 functionclock_12h ()9 {Ten varToday =NewDate ();//Get current Time One //gets the year, month, day, month in the date () function is calculated from 0-11 A varYear =today.getfullyear (); - varmonth = Today.getmonth () +1; - varDate =today.getdate (); the varhour = Today.gethours ();//get hours, minutes, seconds - varminute =today.getminutes (); - varSecond =today.getseconds (); - + varApm= "AM";//Show by default morning: AM - if(HOUR>12)//display by 12-hour system + { AHour=hour-12; atApm= "PM" ; - } - varWeekday = 0; - Switch(Today.getday ()) { - Case0: -Weekday = "Sunday"; in Break; - Case1: toWeekday = "Monday"; + Break; - Case2: theWeekday = "Tuesday"; * Break; $ Case3:Panax NotoginsengWeekday = "Wednesday"; - Break; the Case4: +Weekday = "Thursday"; A Break; the Case5: +Weekday = "Friday"; - Break; $ Case6: $Weekday = "Saturday"; - Break; - } the - /*set the content of the div to the current time*/Wuyidocument.getElementById ("Myclock"). innerhtml= "; the - } Wu /*call CLOCK_12H () after specifying milliseconds per interval using setinterval ( )*/ - varMyTime = SetInterval ("clock_12h ()", 1000); About $</script> - - -<body> A<div id= "Myclock" ></div> +</body> theJS implementation 12-hour clock