Discuz!官方免费开源建站系统

 找回密码
 立即注册
搜索

[发布] 【海外论坛专用插件/代码】海外当地时间与北京时间对照代码

[复制链接]
林三善 发表于 2012-4-14 22:12:38 | 显示全部楼层 |阅读模式
新加坡门户网底部中国时间与新加坡时间显示代码,可以适合给海外任何国家使用,只需要修改时差与国家名字即可,

以下是直排显示效果,效果图:

1.png

代码如下:
  1. <form name="clock">
  2. <table cellpadding="0" cellspacing="0">
  3. <tr>
  4. <td><table cellpadding="0" cellspacing="0" height="17">
  5. <tr>
  6. <td align="center" bgcolor="#000000" width="75" height="17"><font size="2" color="#FFFFFF"><B>北京时间</B></font></td>
  7. <td><input type="text" size="8" name="local" style= "border-style:none;background:transparent; font-size:14px; font-weight:bold;text-decoration:none;color:#000000; font-family:'arial';"></td>
  8. </tr>
  9. </table></td>
  10. </tr>
  11. <tr>
  12. <td colspan="2"height="3"></td>
  13. </tr>
  14. <tr>
  15. <td><table cellpadding="0" cellspacing="0" height="17">
  16. <tr>
  17. <td align="center" bgcolor="#AA0000" width="75" height="17"><font size="2" color="#FFFFFF"><B>新加坡时间</B></font></td>
  18. <td><input type="text" size="8" name="singapore" style= "border-style:none;background:transparent; font-size:14px; font-weight:bold;text-decoration:none;color:#000000; font-family:'arial';"></td>
  19. </tr>
  20. </table></td>
  21. </tr>
  22. </table>
  23. </form>
  24. <script language="javascript" src="http://counter.sina.com.cn/time?fm=JS"></script>
  25. <script language="JavaScript">
  26. t=StandardBJTime*1000+2592000000;
  27. <!-- Begin
  28. function GetTime() {
  29. var dt = new Date(t);
  30. var def = dt.getTimezoneOffset()/60;
  31. var gmt = (dt.getHours() + def);
  32. var summer = false;
  33. document.clock.local.value =(IfZero(dt.getHours()) + ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds()));
  34. var ending = ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds());
  35. if(dt.getMonth()>=3&&dt.getMonth()<10)summer = true;
  36. if(dt.getMonth()==2&&dt.getDate()>=25){
  37. if((dt.getDate()-25)>=dt.getDay())summer = true;
  38. }
  39. if(dt.getMonth()==9&&dt.getDate()>=25){
  40. if((dt.getDate()-25)>=dt.getDay())summer = false;
  41. }
  42. if(summer == true){
  43. var singapore =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 8));
  44. }else{
  45. var singapore =check24(((gmt + 1) > 24) ? ((gmt + 1) - 24) : (gmt + 1));
  46. }
  47. document.clock.singapore.value = (IfZero(singapore) + ending);
  48. var _GMT =check24(((gmt) > 24) ? ((gmt) - 24) : (gmt));
  49. setTimeout("GetTime()", 1000);
  50. t=t+1000;
  51. }
  52. function IfZero(num) {
  53. return ((num <= 9) ? ("0" + num) : num);
  54. }
  55. function check24(hour) {
  56. return (hour >= 24) ? hour - 24 : hour;
  57. }
  58. javascript:GetTime();
  59. // End -->
  60. </script>
  61. </td>
  62. </tr>
  63. </table>
复制代码
以下是横排样式,效果如下:

2.png

代码如下:
  1. <form name="clock">
  2. <table border="0" align="center">
  3. <tr>
  4. <td ><table cellpadding="0" cellspacing="0" >
  5. <tr>
  6. <td align="center" bgcolor="#000000" width="75" ><font size="2" color="#FFFFFF"><B>北京时间</B></font></td>
  7. <td><input type="text" size="4" name="local" style= "border-style:none;background:transparent; font-size:14px; font-weight:bold;text-decoration:none;color:#000000; font-family:'arial';"></td>
  8. </tr>
  9. </table></td>
  10. <td ><table cellpadding="0" cellspacing="0">
  11. <tr>
  12. <td align="center" bgcolor="#AA0000" width="75" ><font size="2" color="#FFFFFF"><b>新加坡时间</b></font></td>
  13. <td><input type="text" size="4" name="singapore" style= "border-style:none;background:transparent; font-size:14px; font-weight:bold;text-decoration:none;color:#000000; font-family:'arial';" /></td>
  14. </tr>
  15. </table></td>
  16. </tr>
  17. </table>
  18. </form>
  19. <script language="javascript" src="http://counter.sina.com.cn/time?fm=JS"></script>
  20. <script language="JavaScript">
  21. t=StandardBJTime*1000+2592000000;
  22. <!-- Begin
  23. function GetTime() {
  24. var dt = new Date(t);
  25. var def = dt.getTimezoneOffset()/60;
  26. var gmt = (dt.getHours() + def);
  27. var summer = false;
  28. document.clock.local.value =(IfZero(dt.getHours()) + ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds()));
  29. var ending = ":" + IfZero(dt.getMinutes()) + ":" + IfZero(dt.getSeconds());
  30. if(dt.getMonth()>=3&&dt.getMonth()<10)summer = true;
  31. if(dt.getMonth()==2&&dt.getDate()>=25){
  32. if((dt.getDate()-25)>=dt.getDay())summer = true;
  33. }
  34. if(dt.getMonth()==9&&dt.getDate()>=25){
  35. if((dt.getDate()-25)>=dt.getDay())summer = false;
  36. }
  37. if(summer == true){
  38. var singapore =check24(((gmt + 2) > 24) ? ((gmt + 2) - 24) : (gmt + 8));
  39. }else{
  40. var singapore =check24(((gmt + 1) > 24) ? ((gmt + 1) - 24) : (gmt + 1));
  41. }
  42. document.clock.singapore.value = (IfZero(singapore) + ending);
  43. var _GMT =check24(((gmt) > 24) ? ((gmt) - 24) : (gmt));
  44. setTimeout("GetTime()", 1000);
  45. t=t+1000;
  46. }
  47. function IfZero(num) {
  48. return ((num <= 9) ? ("0" + num) : num);
  49. }
  50. function check24(hour) {
  51. return (hour >= 24) ? hour - 24 : hour;
  52. }
  53. javascript:GetTime();
  54. // End -->
  55. </script>
复制代码
使用方法,只需要修改代码中的新加坡为您所在国家的名字,以及时差改成你所在国家的时差数目即可,如果有不明白,可以到新加坡门户网http://bbs.oksingapore.com/thread-90242-1-1.html 求助,因为这里不一定及时回复!
回复

使用道具 举报

朴素 发表于 2012-4-14 22:15:06 | 显示全部楼层
不错的插件,对国外使用DZ的用户很有用吧。
回复

使用道具 举报

1314学习网 发表于 2012-4-15 11:31:50 | 显示全部楼层
看下。。。。。。
回复

使用道具 举报

yangkpnx 发表于 2012-4-26 12:56:20 | 显示全部楼层
感谢分享。。
回复

使用道具 举报

爱哭爱笑1 发表于 2013-2-27 13:56:40 | 显示全部楼层
新加坡
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-11-22 09:34 , Processed in 0.119540 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表