Home>

I would like to log in JST time on a PC in any environment.
(Even with English OS, even if the time zone is set to another country)

By the way, I found that when using the NOW function, it depends on the time zone, so
For example, if the area was changed to the United States, it was NG because the American time was acquired.

For now, I'm thinking that I should adjust +9 hours after getting the UTC time,
I haven't learned as much as I want.

What I tried

[Reference source 1]
https://www.366service.com/jp/qa/365938f2e4504e7ec8a8f445f0b47779

[Excerpt from the URL]

Set dateTime = CreateObject ("WbemScripting.SWbemDateTime")
dateTime.SetVarDate (now ())
wscript.echo "Local Time:"&dateTime
wscript.echo "UTC Time:"&dateTime.GetVarDate (false)

I gave up because it seems that I can't process numbers (+9 hours) later with this method. .. ..

[Reference source 2]
http://www.wmifun.net/sample/win32_utctime.html

[Code excerpt from URL]

Option Explicit
'Define and generate various objects used in WMI.
Dim oClassSet
Dim oClass
Dim oLocator
Dim oService
Dim sMesStr
'Connect to your local computer.
Set oLocator = WScript.CreateObject ("WbemScripting.SWbemLocator")
Set oService = oLocator.ConnectServer
'Specify the query condition in WQL.
Set oClassSet = oService.ExecQuery ("Select * From Win32_UTCTime")
'Analyze the collection.
For Each oClass In oClassSet
sMesStr = sMesStr&oClass.Hour&":"&oClass.Minute&":"&oClass.Second&vbCrLf
Next
MsgBox ("Information about UTC (Coordinated Universal Time)."&VbCrLf&vbCrLf&sMesStr)
'Clean up the various objects used.
Set oClassSet = Nothing
Set oClass = Nothing
Set oService = Nothing
Set oLocator = Nothing

In this case, it could not be obtained in hh: mm: ss format.
7:08:05 becomes 7: 8: 5. .. ..