excel - 使用 Windows api TimeZoneInfo ConvertTimeFromUtc
问题描述
在powershell中我可以使用windows系统api
$estzone = [System.TimeZoneInfo]::FindSystemTimeZoneById("Eastern Standard Time")
$esttime = [System.TimeZoneInfo]::ConvertTimeFromUtc($test2, $estzone)
"GMT= " +$test2 + " EST =" + $esttime
我似乎无法在 VB 中引用 FindSystemTimeZoneById 或 ConvertTimeFromUtc
我努力了
Option Explicit
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(0 To 31) As Integer
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(0 To 31) As Integer
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
Private Enum TIME_ZONE
TIME_ZONE_ID_INVALID = 0 ' Cannot determine DST
TIME_ZONE_STANDARD = 1 ' Standard Time, not Daylight
TIME_ZONE_DAYLIGHT = 2 ' Daylight Time, not Standard
End Enum
Private Declare PtrSafe Function FindSystemTimeZoneById Lib "kernel32" (lpTimeZone As String) As TIME_ZONE_INFORMATION
Private Declare PtrSafe Function ConvertTimeFromUtc Lib "kernel32" (lpSystemTime As Date, pTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Function GetLocalTimeFromGMTerc(GMTTime As Date)
Dim estzone As TIME_ZONE_INFORMATION
Dim esttime As Date
estzone = FindSystemTimeZoneById("Eastern Standard Time")
esttime = ConvertTimeFromUtc(GMTTime, estzone)
GetLocalTimeFromGMTerc = esttime
End Function
这似乎可以编译/运行,但给出“公式中使用的值是错误的数据类型”我认为我做错了。有什么帮助吗?
谢谢!
解决方案
推荐阅读
- c# - 如何在 Razor Pages 中更改 DisplayFor 返回的文本?
- javascript - 如何在表格中添加链接
- swift - 如何快速将值与 Payfort 特定的验证 OTP 集成?
- mysql - 使用 vb.net 中的 datagridview 从数据库显示数据的问题
- kdb - kdb+/q 脚本如何编码-解码字符串
- amazon-web-services - 从 AWS 上的 EBS 快照还原后是否必须重新安装软件包
- blazor - 优化服务器端 Blazor 应用程序
- python-3.x - Python3 eyed3 模块,从 mp3 文件中读取评论?
- amazon-web-services - 如何在 AWS API 网关中配置 $default 路径?
- java - 如何在加工中在 Y 坐标上制作重复 3D 球?