en da da da nb da da da es da en en az en en en da en en en en en en en en en en en en en en en en en en en en en en en en kn en en en id en en ko de en fa en da en en en hi es fr en en ko da en da en da hbs_lat en en en tr en en ko de en fa en da hbs_lat en en en en en en en en en en en ko de en da en da fr en en hi es oc en en ko da en da en da fa tr en en tr en en en en en en pt en da da da es en da da da en da da da da en da es en da da da en da da da da en
Set-Date (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn
Denne browser understøttes ikke længere.
Opgrader til Microsoft Edge for at drage fordel af de nyeste funktioner, sikkerhedsopdateringer og teknisk support.
Download Microsoft Edge Flere oplysninger om Internet Explorer og Microsoft Edge
Indholdsfortegnelse Læs på engelsk Gem Feedback Rediger
Changes te system time on te computer to a time that you specify.
Set-Date [-Date]   [-DisplayHint  ] [-WhatIf] [-Confirm] [ ]
Te Set-Date cmdlet changes te system date and time on te 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 te Date parameter. To specify a change interval, use te Adjust parameter.
Example 1: Add three days to te system date
This command adds three days to te current system date. It does not affect te time. Te command uses te Date parameter to specify te date.
Te Get-Date cmdlet returns te current date as a DateTime object. Te DateTime object's AddDays method adds a specified number of days (3) to te current DateTime object.
Example 2: Set te system clock back 10 minutes
This example sets te current system time back by 10 minutes.
Te Adjust parameter allows you to specify an interval of change (minus ten minutes) in te standard time format for te locale.
Te DisplayHint parameter tells PowerShell to display only te time, but it does not affect te DateTime object that Set-Date returns.
Set-Date -Adjust -0:10:0 -DisplayHint Time
Example 3: Set te date and time to a variable value
These commands change te system date and time on local computer to te date and time saved in te variable $T. Te first command gets te date and stores it in $T.
Te second command uses te Date parameter to pass te DateTime object in $T to te Set-Date cmdlet.
$T = Get-Date Set-Date -Date $T
Example 4: Add 90 minutes to te system clock
These commands advance te system time on te local computer by 90 minutes.
Te first command uses te New-TimeSpan cmdlet to create a TimeSpan object with a 90-minute interval, and saves it in te $90mins variable.
Te second command uses te Adjust parameter of Set-Date to adjust te date by te value of te TimeSpan object in te $90mins variable.
$90mins = New-TimeSpan -Minutes 90 Set-Date -Adjust $90mins
Specifies te value for which this cmdlet adds or subtracts from te current date and time. can type an adjustment in standard date and time format for your locale or use te Adjust parameter to pass a TimeSpan object from New-TimeSpan to Set-Date.
Prompts you for confirmation before running te cmdlet.
Changes te date and time to te specified values. You can type a new date in te short date format and a time in te standard time format for your locale. Or, you can pass a DateTime object from Get-Date.
If you specify a date, but not a time, Set-Date changes te time to midnight on te specified date. If you specify only a time, it does not change te date.
Specifies which elements of te date and time are displayed.Te acceptable values for this parameter are:
Date - displays only te date.
Time - displays only te time.
DateTime - displays te date and time.
This parameter affects only te display. It does not affect te DateTime object that Get-Date retrieves.
Shows what would happen if te cmdlet runs. Te cmdlet is not run.
You can pipe a date to Set-Date.
Set-Date returns an object that represents te date that it set.
Use this cmdlet cautiously when changing te date and time on te computer. Te change might prevent te computer from receiving system-wide events and updates that are triggered by a date or time. Use te WhatIf and Confirm parameters to avoid errors.
You can use standard .NET methods with te DateTime and TimeSpan objects used with Set-Date, such as AddDays, AddMonths, and FromFileTime. For more information, see DateTime Methods and TimeSpan Methods in te .NET SDK.
Indsend og få vist feedback om
Dette produkt Denne side
Få vist feedback på hele siden
Beskyttelse af personlige oplysninger & Cookies
Beskyttelse af personlige oplysninger & Cookies