Change the computer system time.
Syntax
Set-Date { [-date] DateTime] | [-adjust] TimeSpan }
[-displayHint {Date | Time | DateTime}]
[-year int] [-month int] [-day int] [-hour int]
[-whatIf] [-confirm] [CommonParameters]
Key
-date DateTime
Change the date and time to DateTime.
Pass a Date-Time object from Get-Date or enter a date in
the short date format for your locale.
The time will default to midnight on the specified date.
If you specify only a time, the date will not be changed.
-displayHint DisplayHintType
Display only the Date, only the Time or the DateTime.
This does not affect the DateTime object that is retrieved.
-adjust TimeSpan
Add or subtract TimeSpan from the current date and time.
Use the standard date and time format for your locale
or pass a TimeSpan object from New-TimeSpan.
-whatIf
Describe what would happen if you executed the command without
actually executing the command.
-confirm
Prompt for confirmation before executing the command.
CommonParameters:
-Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.
Examples
Add two days to the current system date, without changing the time:
PS C:\>Set-Date -Date (Get-Date).AddDays(2)
Set the current system time back by 30 minutes:
PS C:\>set-date -adjust -0:30:0
Advance the system time on the local computer forwards by 30 minutes:
PS C:\>$halfhr = new-timespan -minutes 30
PS C:\>set-date -adjust $halfhr
“I always play women I would date” - Angelina Jolie
Related:
Get-Date - Get current date and time
New-Timespan - Create a timespan object
Equivalent bash command: date - Display or change the date