How to retrieve the updated date in batch

Question:

I made a bat file that changes the windows date.

However, I also need another bat file, so when executed, it retrieves the updated date.

How to proceed?

Answer:

  • Saving the date is possible, but the best thing is to synchronize the data/hora via the internet , where it is possible to get updated in a more practical and precise way, for that, use this código :
@echo off & color 0a && setlocal enableextensions enabledelayedexpansion

tzutil /s "E. South America Standard Time"
w32tm /query /status 2>nul >nul 

if not !errorlevel! == 0  (       
    w32tm /register && net start w32time
    w32tm /config /manualpeerlist:a.ntp.br /syncfromflags:manual /reliable:yes /update
    w32tm /resync /force /nowait &&  net stop w32time 
    w32tm /unregister  
   ) else (
    w32tm /config /manualpeerlist:a.ntp.br /syncfromflags:manual /reliable:yes /update
    w32tm /resync /force /nowait &&  net stop w32time 
   )
Scroll to Top