我有一个在美国和印度时区共享并在本地运行的 Access 应用程序。我需要可靠地为记录更改添加时间戳。用户 1 和用户 2 可能会在时钟的两侧接触同一数据集中的记录。
用户将根据每个定期 SYNC 发送的时间戳从 SQL 服务器推/拉时间戳记录。我做了一个初步的函数,它简单地将 Now() 值作为时间戳,但我可以看到这将如何成为生产中的一个问题。
有什么建议来处理这个时间戳的事情吗?
试试这个
Option Compare Database
Option Explicit
Private Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TimeZoneInfo) As Long
Private Type SystemTime
intYear As Integer
intMonth As Integer
intwDayOfWeek As Integer
intDay As Integer
intHour As Integer
intMinute As Integer
intSecond As Integer
intMilliseconds As Integer
End Type
Private Type TimeZoneInfo
lngBias As Long
intStandardName(32) As Integer
intStandardDate As SystemTime
intStandardBias As Long
intDaylightName(32) As Integer
intDaylightDate As SystemTime
intDaylightBias As Long
End Type
Public Function GetUTCOffset() As Date
Dim lngRet As Long
Dim udtTZI As TimeZoneInfo
lngRet = GetTimeZoneInformation(udtTZI)
GetUTCOffset = udtTZI.lngBias / 60 / 24
End Function
我在这里找到了它:
http://www.dbforums.com/microsoft-access/1000377-now-users-using-different-time-zones.html