In tip 9828, we retrieved the current
YYYY MM DD HH MN SS oGMT DST, where oGMT is the signed offset from GMT.
I have script DateTimeUTC.bat to return the UTC (GMT) date time.
The syntax for using DateTimeUTC.bat is:
call DateTimeUTC YYYY MM DD HH MN SS oGMT YYYYUTC MMUTC DDUTC HHUTC MNUTC SSUTC
Where:
YYYY is the 4 digit year of the date / time you wish convert to UTC. MM is the 2 digit month of the date / time you wish convert to UTC. DD is the 2 digit day of the date / time you wish convert to UTC. HH is the 2 digit hour of the date / time you wish convert to UTC. MN is the 2 digit minute of the date / time you wish convert to UTC. SS is the 2 digit second of the date / time you wish convert to UTC. oGMT is the signed offset from GMT. YYYYUTC is a call directed environment variable that will contain the 4 digit UTC year. MMUTC is a call directed environment variable that will contain the 2 digit UTC month. DDUTC is a call directed environment variable that will contain the 2 digit UTC day. HHUTC is a call directed environment variable that will contain the 2 digit UTC hour. MNUTC is a call directed environment variable that will contain the 2 digit UTC minute. SSUTC is a call directed environment variable that will contain the 2 digit UTC second.DateTimeUTC.bat contains:
@echo off if \{%13\}==\{\} @echo Syntax: DateTimeUTC YYYY MM DD HH MN SS OGMT YYYYUTC MMUTC DDUTC HHUTC MNUTC SSUTC setlocal if exist "%TEMP%\DateTimeUTC.VBS" goto getit @echo.Dim objShell, objArgs>"%TEMP%\DateTimeUTC.VBS" @echo.Set objShell = CreateObject("WScript.Shell")>>"%TEMP%\DateTimeUTC.VBS" @echo.Set objArgs = WScript.Arguments>>"%TEMP%\DateTimeUTC.VBS" @echo.tzo=objArgs(1)>>"%TEMP%\DateTimeUTC.VBS" @echo.tzo=-tzo>>"%TEMP%\DateTimeUTC.VBS" @echo.Wscript.Echo DateAdd("h", tzo, objArgs(0))>>"%TEMP%\DateTimeUTC.VBS" :getit set dt="%2/%3/%1 %4:%5:%6" set tzo=%7 shift shift shift shift shift shift shift for /f "Tokens=1-6 delims=.:/-, " %%a in ('cscript //nologo "%TEMP%\DateTimeUTC.VBS" %dt% %tzo%') do ( set /a m=100%%a%%100 set /a d=100%%b%%100 set /a y=10000%%c%%10000 set /a h=100%%d%%100 set /a n=100%%e%%100 set /a s=100%%f%%100 ) if %m% LSS 10 set m=0%m% if %d% LSS 10 set d=0%d% if %h% LSS 10 set h=0%h% if %n% LSS 10 set n=0%n% if %s% LSS 10 set s=0%s% if %y% LSS 100 set y=20%y% endlocal&set %1=%y%&set %2=%m%&set %3=%d%&set %4=%h%&set %5=%n%&set %6=%s%
0 comments
Hide comments