Mastering Time with Shell and PowerShell
Overview
Explore an array of shell and PowerShell commands focused on time management, including last boot-up time, system boot time, and time zone adjustments.
DATE
Display the current date using the DATE command:
wmic
LastBootUpTime
Retrieve the last boot-up time using Windows Management Instrumentation Command-line (wmic):
SystemUpTime
Determine system uptime, showing the duration since the last boot-up:
systeminfo
System Boot Time
Obtain the system boot time using the systeminfo command in conjunction with find:
w32tm
The w32tm command-line tool is used for diagnosing and configuring the Windows Time Service.
configuration
Check the current configuration:
Register and Unregister
Register or unregister the Windows Time Service:
resync
Resynchronize the system clock with the configured time source:
query source
Display the current time source and related information:
Win32_OperatingSystem
LastBootUpTime
Calculate the time elapsed since the last boot-up in PowerShell by subtracting the LastBootUpTime from the current date:
Alternatively, execute the same command within a shell environment:
TIME
Obtain the current system time using the TIME command with the /T flag:
tzutil
Display the current time zone:
Show the current time zone:
Change time zone
Change the system time zone using the tzutil command by providing the desired time zone as an argument after the /s flag. For example, set the time zone to Eastern Standard Time: