Change the computer system time.
Syntax Set-Date { [-date] DateTime] | [-adjust] TimeSpan } [-displayHint {Date | Time | DateTime}] [-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. -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. -DisplayHint DisplayHintType Display only the Date, only the Time or the DateTime. This does not affect the DateTime object that is retrieved. -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, -WarningAction, -WarningVariable, -OutBuffer -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 PowerShell Cmdlets:
Get-Date - Get current date and time.
New-Timespan - Create a timespan object.
Equivalent bash command: date - Display or change the date.