Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. //function clockLocale():顯示當前本地時間
  2. function showTimeLocale() {
  3. //建立一date()物件
  4. var date = new Date();
  5. // 在網頁的#clock裡顯示date.toLocaleTimeString()
  6. document.getElementById("clockL").innerHTML = date.toLocaleTimeString();
  7. }
  8.  
  9. //function clock():顯示當前標準時間
  10. function showTimeStanard() {
  11. var date = new Date();
  12. // 在網頁的#clock2裡顯示date.toTimeString()
  13. document.getElementById("clockS").innerHTML = date.toTimeString();
  14.  
  15. // 注意兩個method的輸出格式不同
  16. }
  17.  
  18.  
  19. var clockL;
  20. var clockS;
  21.  
  22. function clockLSwitch(bln){
  23. // true=Run,false=stop
  24. if(bln){
  25. clockL=setInterval(showTimeLocale,1000);
  26. console.log("TimeLocale on");
  27. }
  28. else{
  29. window.clearInterval(clockL);
  30. console.log("TimeLocale off");
  31. }
  32. }
  33.  
  34. function clockSSwitch(bln){
  35. // true=Run,false=stop
  36. if(bln){
  37. clockS=setInterval(showTimeStanard,1000);
  38. console.log("TimeStandard on");
  39. }
  40. else{
  41. window.clearInterval(clockS);
  42. console.log("TimeStandard off");
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement