This article is written assuming you have your operating system already updated to the latest versions available.

On Windows


You have the choice of doing it with the graphical user interface (GUI), command prompt or with PowerShell. Lets just say you do not have access to the GUI, you should have direct access to the command line interface (CLI) or power shell to do the below commands.

If you do happen to have GUI access but want to feel cool using the CLI, make sure you run it as administrator to be able to run the commands.

In Command Prompt

Run date and fill in the prompt of yy-mm-dd and hit enter. You then run time and fill in the prompt of hh:mm:ss.ms
This format also accepts military time (ie 24hours)

Easy, right? Good.

In Powershell

The fancy command prompt cousin that have much more to offer over bat scripts.

Run get-date to obtain the current time and date (like below picture) and run set-date and follow the format of Month date year hour:minutes:seconds AMorPM and hit enter.


Linux

General way would be to use timedatectl. You could input the command of timedatectl -h to obtain more information on each and every other combinations you could do with the command.

Results from timedatectl -h

Use timedatectl status to know your current configurations.

result of timedatectl status

The command sudo timedatectl set-time "hh:mm:ss" will get your servers time set quickly.

If you want your time and date to be properly assigned based on the zone you are physically located, use the command sudo timedatectl set-timezone "Continent/City" . You will see a huge list of Continent/City combo’s using sudo timedatectl list-timezones.

If we wanted to set our timezone to Canada, Quebec, Montreal, because of time zone rules and where the time servers are located, we’ll have to use America/Toronto.

If you are located somewhere else, I suggest to run the command sudo timedatectl list-timezones | grep "Continent" and you’ll see a a list of each city located in your continent.

Changed time zone to the East Coast -5

And because timedatectl is part of the Linux operating system, it is available on both Debian and Red Hat based OS.

Last option that I know of would be to use the command sudo dpkg-reconfigure tzdata which will bring up a GUI (graphical user interface).

It’s very straightforward and takes only two or three steps to to go through.

Graphical User Interface to Set your time zone which will automatically set the time and date for you

You have other ways how to configure your time and date on both operating systems? Feel free to share them below or to ask questions

Categories:

1 thought on “Setting up Time and Date on Both Linux and Windows”

  1. ehmahgnkgy says:

    Muchas gracias. ?Como puedo iniciar sesion?

Leave a Reply

Your email address will not be published. Required fields are marked *