Skip to content

Instantly share code, notes, and snippets.

@joshschmelzle
Last active May 30, 2018 12:34
Show Gist options
  • Save joshschmelzle/af52ef66da8c03022504a7540c1bd32f to your computer and use it in GitHub Desktop.
Save joshschmelzle/af52ef66da8c03022504a7540c1bd32f to your computer and use it in GitHub Desktop.
Prints the local date and time in ISO format to the screen on a Windows machine
@echo off
for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j
set ldt=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2% %ldt:~8,2%:%ldt:~10,2%:%ldt:~12,6%
echo local time is %ldt%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment