zoukankan      html  css  js  c++  java
  • asp.net中客户端保持与服务器时间一致

    代码是我从一个网站看到的代码改过来的。

    后台代码中将服务器时间显示出来

    Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"time""<script type=\"text/javascript\">\r\n\tvar strTime=\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\";\r\n</script>\r\n");

    前台使用javascript进行转换

    strTime=strTime.replace(/(-)/g,"/");
    var datNow=new Date(strTime);  
    var datLocalNow=new Date();
    datC
    =datLocalNow-datNow; 
    function GetServerTime()
    {
        
    var datNow=new Date(new Date()-datC);        
        
    var strYear=datNow.getFullYear();
        
    var strMonth=datNow.getMonth()+1;
        strMonth
    =strMonth<10?"0"+strMonth:strMonth;
        
    var strDay=datNow.getDate();
        strDay
    =strDay<10?"0"+strDay:strDay;
        
    var strHour=datNow.getHours();
        strHour
    =strHour<10?"0"+strHour:strHour;
        
    var strMinite=datNow.getMinutes();
        strMinite
    =strMinite<10?"0"+strMinite:strMinite;
        
    var strSecond=datNow.getSeconds();
        strSecond
    =strSecond<10?"0"+strSecond:strSecond;
        $(
    "time").innerHTML=strYear+""+strMonth+""+strDay+"日 "+strHour+":"+strMinite+":"+strSecond                               
    }

    GetServerTime();
    setInterval(
    "GetServerTime()",1000); 



    基于JQ的插件封装

    JQ
  • 相关阅读:
    Redis进阶实践之一VMWare Pro虚拟机安装和Linux系统的安装
    HTTP常见面试题
    HBase WAL原理学习
    HBase TableExistsException: hbase:namespace
    HBase常用操作之namespace
    Hbase原理、基本概念、基本架构
    hbase 修复 hbase hbck
    hbase数据备份或者容灾方案
    Hbase 日常运维
    HBase shell scan 模糊查询
  • 原文地址:https://www.cnblogs.com/liydotnet/p/1111749.html
Copyright © 2011-2022 走看看