Last active
October 15, 2020 09:06
-
-
Save agungsp2000/33273639678407984a8b7f55a9635747 to your computer and use it in GitHub Desktop.
Set Windows local time from website header using CURL, need this because NTP is blocked cant do auto sync, use task scheduler to do this batch file recurringly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cls | |
echo off | |
rem Get date from google.com header and put it into file | |
@curl -s -I www.google.com | findstr "Date:" > datetime.txt | |
rem set variabel timenow as that file content, its in GMT so need to convert it into local timezone | |
@set /p timenow=< datetime.txt | |
@rem echo Jam GMT: %timenow% | |
rem Get the time only | |
@FOR /F "TOKENS=5,6* DELIMS= " %%G IN ("%timenow%") DO SET "timegmt=%%H" | |
@echo Jam GMT : %timegmt% | |
rem parsing the hour to set to local timezone, change + 7 to yours | |
@set "jam=%timegmt:~0,2%" | |
rem remove leading 0 if exists, make sure add in task scheduler at time when add or minus your timezone, it doesnt exceed 24 | |
@set jam=%jam:0=% | |
@set /a jam = %jam% + 7 | |
rem get the minute and second of the time | |
@set "menit=%timegmt:~3,2%" | |
@set "detik=%timegmt:~6,2%" | |
rem set the time using string combined from the hour:minute:time | |
echo Jam WIB : %jam%:%menit%:%detik% | |
@time %jam%:%menit%:%detik% | |
echo ... | |
echo Time Set |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment