Reputation: 17
Dim dt As Object, utc As Date
Set dt = CreateObject("WbemScripting.SWbemDateTime")
dt.SetVarDate Now
utc = dt.GetVarDate(False)
Hello! I just saw this code somewhere in this page, but this code converts the time to UTC.
But can someone help me to convert it to PST instead?
Thank you!
Upvotes: 0
Views: 616
Reputation: 96753
Consider:
Sub TimeOnMyHands()
Dim dt As Object, utc As Date, pst As Date
Set dt = CreateObject("WbemScripting.SWbemDateTime")
dt.SetVarDate Now
utc = dt.GetVarDate(False)
pst = utc - TimeSerial(8, 0, 0)
MsgBox utc & vbCrLf & pst
End Sub
Upvotes: 3