X

How to Set Date and Time Using PowerShell on Windows

The system date and time in Windows can be modified through PowerShell, a Windows scripting environment and command-line shell. The process requires administrative privileges and involves a simple command. Here are examples of how to accomplish this task.

Steps to Set Date and Time in PowerShell

Step 1: Obtain Administrative Access

Ensure you are logged in to your Windows desktop or server with an account that possesses administrative privileges. This is crucial as changing system settings requires elevated permissions.

Step 2: Launch PowerShell

Open PowerShell, which can be found in the Start Menu, or by searching for it in the Windows search bar.

Step 3: Run the Set-Date Cmdlet

In the PowerShell window, type the following command:

Set-Date -Date "MM/DD/YYYY HH:MM"

Replace MM/DD/YYYY with the desired date, and HH:MM with the desired time, then press Enter.

For example:

Set-Date -Date "01/10/2024 07:53"

This command sets the system's date and time to January 10, 2024, at 07:53.

Frequently Asked Questions

Can I set the time in a 24-hour format?

Yes, PowerShell accepts time in both 12-hour and 24-hour formats. Ensure AM or PM is specified if using the 12-hour format.

How can I verify the current system date and time?

To check the current system date and time, use the Get-Date cmdlet in PowerShell.

Is it possible to set only the date or only the time?

Yes, you can modify either the date or time independently. Use the format:

Set-Date -Date "MM/DD/YYYY"

for a date only, or

Set-Date -Date "HH:MM"

for time only.

Does this change affect all user accounts on the system?

Yes, changing the system date and time via PowerShell affects all users on the system as it's a global change.

What should I do if I receive an error?

Ensure you have administrative privileges and that you're entering the date and time in the correct format. If the problem persists, check for restrictions or policies on your system that might prevent changes to date and time settings.

Setting the date and time through PowerShell offers a quick and scriptable method suitable for both individual workstations and server environments. It's particularly useful for administrators managing multiple systems or automating system configuration tasks.

Karim Buzdar: About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various websites.
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings