你的位置:首页 > Java教程

[Java教程]JQuery 世界时间


根据表格的时间显示表格的时间,本机的时间,韩国的时间

 1 <%@ Page Language="C#" AutoEventWireup ="true" CodeBehind ="WebForm1.aspx.cs" Inherits="time.WebForm1" %> 2  3 <!DOCTYPE html> 4  5 <html "http://www.w3.org/1999/xhtml"> 6 <head runat="server"> 7   <title >123 </title> 8   <script src="Scripts/jquery-1.10.2.min.js"></script> 9    <script type ="text/javascript">10       $(function() {11          $("table tr td").each(function() {12            var normalDate = $(this).html();13          if (normalDate != "") {14            var d1 = new Date(normalDate);15            if (d1 != null) {16              var year = d1.getFullYear();17              var month = d1.getMonth() + 1;18              var day = d1.getDate();19              var hour = d1.getHours();20              var minute = d1.getMinutes();21              var timezone = Math.abs(d1.getTimezoneOffset()) / 60;22              if (timezone < 10)23                timezone = "0" + timezone;24              $("#t2").html("本机时间:" + " " + year + "/" + month + "/" + day + " " + hour + ":" + minute + " +" + timezone);25             }26 27            var d2 =new Date(normalDate);28            if (d2 != null) {29              d2.setMinutes(d2.getMinutes() + d2.getTimezoneOffset() + 540)//韩国是54030              var year = d2.getFullYear();31              var month = d2.getMonth() + 1;32              var day = d2.getDate();33              var hour = d2.getHours();34              var minute =d2.getMinutes();35              var timezone = "09";36              $("#t3").html("韩国时间:" + " " + year + "/" + month + "/" + day + " " + hour + ":" + minute + " +" + timezone);37             }38           }39         })40       });41      </script>42   </head>43   <body>44     <table class ="TimeField1" style="width: 100%;">45       <tr id="t1">46         <td> 2015/11/09 01:39 +03</td >47       </tr>48       <tr id="t2">49       </tr>50       <tr id="t3">51       </tr>52     </table>53   </body>54 55   </html>