PowerShell Logo Small

Set-Date



This is the built-in help made by Microsoft for the command 'Set-Date', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Changes the system time on the computer to a time that you specify.

SYNTAX


Set-Date [-Date] <DateTime> [-DisplayHint {Date | Time | DateTime}] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}]
[-InformationVariable [<System.String>]] [-Confirm] [-WhatIf] [<CommonParameters>]
Set-Date [-Adjust] <TimeSpan> [-DisplayHint {Date | Time | DateTime}] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}]
[-InformationVariable [<System.String>]] [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Set-Date cmdlet changes the system date and time on the computer to a date and time that you specify. You can specify a new date and/or time by typing a string or by
passing a DateTime or TimeSpan object to Set-Date. To specify a new date or time, use the Date parameter. To specify a change interval, use the Adjust parameter.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=294012
Get-Date
New-TimeSpan

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>Set-Date -Date (Get-Date).AddDays(3)



Description

-----------

This command adds three days to the current system date. It does not affect the time. The command uses the Date parameter to specify the date. It uses the Get-Date cmdlet to
get the current date and time and applies the AddDays .NET method for DateTime objects with a value of 3 (days).










-------------------------- EXAMPLE 2 --------------------------

PS C:\>set-date -adjust -0:10:0 -displayHint time



Description

-----------

This command sets the current system time back by 10 minutes. It uses the Adjust parameter to specify an interval of change and the time change (minus ten minutes) in
standard time format for the locale. The DisplayHint parameter tells Windows PowerShell to display only the time, but it does not affect the DateTime object that Set-Date
returns.










-------------------------- EXAMPLE 3 --------------------------

PS C:\>$t = get-date
PS C:\>set-date -date $t



Description

-----------

These commands change the system date and time on the computer to the date and time saved in the variable $t. The first command gets the date and stores it in $t. The second
command uses the Date parameter to pass the DateTime object in $t to the Set-Date cmdlet.










-------------------------- EXAMPLE 4 --------------------------

PS C:\>$90mins = new-timespan -minutes 90
PS C:\>set-date -adjust $90mins



Description

-----------

These commands advance the system time on the local computer by 90 minutes. The first command uses the New-Timespan cmdlet to create a TimeSpan object with a 90-minute
interval, and then it saves the TimeSpan object in the $90mins variable. The second command uses the Adjust parameter of Set-Date to adjust the date by the value of the
TimeSpan object in the $90mins variable.