Java code
1. <script language = "javascript" type = "text/javascript">
2. // use the jQuery page to load directly
3. $ (document). ready (function (){
4. fillDate ();
5 .});
6. // main Time Processing Method
7. function fillDate (){
8. // Date
9. var now = new Date (); // obtain the system Date, that is, Sat Jul 29 08:24:48 UTC + 0800 2006
10. var yy = now. getFullYear (); // year, that is, 2006
11. var mm = now. getMonth () + 1; // capture the month, that is, 07
12. var dd = now. getDate (); // truncate the day, that is, 29
13. var cal = yy + "." + mm + "." + dd;
14. // obtain the time
15. var hh = now. getHours (); // intercept the hour, that is, 8
16. var mm = now. getMinutes (); // capture minutes, that is, 34
17. var ss = now. getTime () % 60000;
18. // obtain the time. Because the time in the system is calculated in milliseconds, the second is obtained through an additional 60000.
19. ss = (ss-(ss % 1000)/1000; // then, the number of milliseconds is processed into seconds.
20. var clock = hh + ':'; // concatenate the obtained parts into a date and time.
21. if (mm <10) clock + = '0'; // string
22. clock + = mm + ':';
23. if (ss <10) clock + = '0 ';
24. clock + = ss;
25. // assign a value to the corresponding position of the page
26. $ (". date" 2.16.html (cal + "" + clock );
27. var timeID = setTimeout (fillDate, 1000 );
28 .}
29. </script>
Thanks to wucf2004, we have achieved new results by improving his methods.
From chenyanqing8899-163-com