Nyari2 aplikasi, gada yg berhasil, pake dimension, nisa, nettime, keblock semua
Akhirnya ada ilham, untuk ambil time di header situs yg bonafid, yg ga keblok, paling jd andelan si google.com via curl
Setelah ngoprek seharian berhasil juga, walau pusing belajarin tools kuno di masa kelam, batch... yang ternyata jadi super dan full feature
Saya taro di github dengan penjelasan inggris, sapa tau manfaat buat yg lain, yakiiin pasti ada yg lebih efisien, namanya juga ngulik sendiri seadanya... yang penting berfungsi jalan, hahaha
Batch ini hanya untuk set waktu ya, asumsi tanggal sangat jarang meleset, kecuali abis batre mobo
This file contains 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 |
No comments:
Post a Comment