日常计算机时间北京时间,现在需要实现世界时的时间、日期,还有个小问题,如何实现以20时为日界,就是过了20点,就算是下一日了,最好有vb代码!

解决方案 »

  1.   


    Option ExplicitPrivate Sub Command1_Click()
        Dim DateOne As Date
        Dim DateTwo As Date    DateOne = CDate("2010-12-8 20:45:30")
        DateTwo = CDate("2011-02-12 20:05:15")
        Debug.Print DateDiff("d", DateOne, DateTwo)
    End Sub
      

  2.   

    你自己创建一个数组,这个数组中包含可选项(也就是世界各地)和格林威治时间的偏差,然后使用DateDiff转换即可。
      

  3.   

    Option ExplicitSub Main()
        Dim dtLocal As Date
        Dim dtGMT As Date
        
        dtLocal = Now()
        Debug.Print "北京时间", dtLocal
        dtGMT = DateAdd("h", -8, dtLocal)
        Debug.Print "格林威治时间", dtGMT
    End Sub
    Option ExplicitSub Main()
        Dim dtLocal As Date
        Dim dtGMT As Date
        
        dtLocal = Now()
        Debug.Print "北京时间", dtLocal
        dtGMT = DateAdd("h", 4, dtLocal)
        Debug.Print "斐济时间", dtGMT
    End Sub
      

  4.   

    用winsock通过时间服务器获取标准时间.
    只要TCP协议链接成功,服务器立即就返回时间了,连数据都不需要发送...时间服务器可以通过搜索,也可以用time.windows.com,time.nist.gov...