
- PowerShell Tutorial
- PowerShell - Home
- PowerShell - Overview
- PowerShell - Environment Setup
- PowerShell - Cmdlets
- PowerShell - Files and Folders
- PowerShell - Dates and Timers
- PowerShell - Files I/O
- PowerShell - Advanced Cmdlets
- PowerShell - Scripting
- PowerShell - Special Variables
- PowerShell - Operators
- PowerShell - Looping
- PowerShell - Conditions
- PowerShell - Array
- PowerShell - Hashtables
- PowerShell - Regex
- PowerShell - Backtick
- PowerShell - Brackets
- PowerShell - Alias
- PowerShell Useful Resources
- PowerShell - Quick Guide
- PowerShell - Useful Resources
- PowerShell - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Powershell - Set System Time
Cmdlet
Set-Date cmdlet is used to set System Time.
In this example, we're using Get-Date to get current date
Type the following command in PowerShell ISE Console
get-date -displayHint time
Output
You can see following output in PowerShell console.
10:04:18 AM
In this example, we're using Set-Date to adjust to 60 minutes.
Type the following commands in PowerShell ISE Console
> $timeToAdd = New-TimeSpan -Minutes -60 > set-date -adjust $timeToAdd
Output
You can see following output in PowerShell console.
Saturday, May 05, 2018 11:05:16 AM
Now revert back to substract added time to current date.
Type the following command in PowerShell ISE Console
> $timeToAdd = New-TimeSpan -Minutes -60 > set-date -adjust $timeToAdd
Output
You can see following output in PowerShell console.
Saturday, May 05, 2018 10:08:54 AM
powershell_dates_timers.htm
Advertisements