How to Set the Date and Time on Raspberry Pi (Desktop & Lite)

For most people, the Raspberry Pi operating system (whatever the one you use) will do this in the background, and it shouldn’t be an issue.
But in some cases, like if you are just getting started on Raspberry Pi or using it without an Internet connection, it can be an issue.
In this post, we’ll see how to fix any date & time issue on Raspberry Pi.

NTP is enabled by default on Raspberry Pi OS, and will connect to an Internet server to set the date and time accordingly.
It’s possible to set date and time manually, from the desktop interface or with the command “sudo date -s ‘YYYY-MM-DD HH:MM:SS’

I will now guide you through the details, and give you a solution that should help in most cases, whatever if you are using a Desktop environment or not, and if your Pi is connected to the Internet or not.

Why are date and time an issue on Raspberry Pi?

Download the Pi Glossary!
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!

On a computer, you’ll rarely think about setting the date and time correctly.
You might configure it after the installation, and will probably forget about it for years.
But on Raspberry Pi, you might have an issue regularly, especially when using it without Internet access, or by not using a recent Raspberry Pi OS version.

The first reason is that Raspberry Pi OS relies on an Internet connection to get and keep the correct date and time.
On the desktop version, there are no ways to set the date and time directly in the Interface, the only thing you can change is the time zone.

Raspberry Pi Bootcamp
Sale: 10% off today.
Take it to the next level.
I'm here to help you get started on Raspberry Pi.
Learn all the skills you need in the correct order.

But the other reason comes from a hardware specificity.
On any computer, there is a battery that allows the computer to “remember” the date and time, even when disconnected from a power source for a long time. On Raspberry Pi, there isn’t such a thing.

Lithium battery on a computer motherboard

On recent Raspberry Pi OS versions (since Stretch I think), a package is included to fix this: “fake-hwclock”. It will store the current date and time in the operating system files, to restore it after a reboot if there is no Internet connection.

If you are using an older Raspbian system, or a different operating system, it might be something to look at before going further, as I will not cover this case in the following.

Reminder: Remember that all my Patreon supporters get access to this website without ads, early access to my videos and much more. You can become part of this community for as little as $3 per month & get all the benefits immediately.

Set Date and Time on Raspberry Pi OS with Desktop

Get My Cheat Sheet!
Grab your free PDF file with all the commands you need to know on Raspberry Pi!

If you are on Raspberry Pis OS, the date and time configuration should be pretty easy if you have any Internet access.
But let’s take a look at what you can do to set it correctly.

Use the welcome wizard

On the first boot on Raspberry Pi OS, a configuration wizard will show up and ask you a bunch of information.
One of them is your location.
Your Pi doesn’t just ask for it out of curiosity, but to set the time zone according to your answer.

Once the timezone set, the operating system will synchronize the system date and time with an Internet server, and display the correct clock depending on your location.
In most cases, you’ll be set after that. The Raspberry Pi will synchronize regularly with a time provider, and it should be ok.

Use the Raspberry Pi configuration tool

If you miss the welcome wizard, or need to change something in your current configuration, you can use the Raspberry Pi configuration tool on your system.

Master your Raspberry Pi in 30 days
Sale: 10% off today.
Download the eBook.
Uncover the secrets of the Raspberry Pi in a 30 days challenge.
Learn useful Linux skills and practice multiples projects.

In the main menu, go to Preferences > Raspberry Pi Configuration.
In the “Localisation” tab, you can change the current time zone:

Choose the one corresponding to your location, and click on “Ok” twice to save the changes.
A few seconds later, the time should be updated in the top-right corner.

On Raspberry Pi OS with Desktop, this is the only control you have directly in the interface.
You can set a different time zone, but can’t set the date and time manually.
To manage this, you need to use the command line.
So, if these tips didn’t help you, keep reading to find other solutions.

Before going further, if you are a bit lost on Raspberry Pi OS Desktop, and need help to get started, I have a solution for you. My Raspberry Pi Bootcamp course will guide you through the first steps, from understanding the hardware to setting up your first OS as a Desktop replacement. I will also guide you to complete your 5 first projects on Raspberry Pi.
You can find more details about this on this page.

Set Date and Time in the command line

If you are using Raspberry Pi OS Lite, or connected via SSH, you don’t have access to these tools. No worry, there are similar alternatives while in the command line.

Use Raspi-config

The easiest way to fix your time zone is to use raspi-config, to get similar results quickly.
Raspi-config is the main configuration tool available on Raspberry Pi OS Lite, allowing you to configure many things, including date and time:

  • Start the tool with this command:
    sudo raspi-config
  • Got to “Localisation options”, then “Timezone”
    raspi config
  • Pick a geographic area and a specific time zone

Once done, the system configuration will be updated with the new date/time.
By the way, you can use this command to display the current date and time:

In one command

So, Raspi-config will help us to do the same thing as in the Desktop interface, but can’t still configure the date and time manually.
The only way to set a custom date is to use the command line.

Master Python on Raspberry Pi
Sale: 10% off today.
Get the eBook.
Do more with your Raspberry Pi, learn the useful concepts and take the shortcuts.
You miss half of the fun of using a Raspberry Pi if you don’t know anything about Python.

Here is the command to set the date and time manually:
sudo date -s 'DATE'
For example:
sudo date -s '2021-01-04 13:04:00'
The date is not required, you can also use:
sudo date -s '13:04:00'
It works the same way.

The date command will handle most date formats, but you can find more information on the GNU website here if you have any doubt.
Use the command “date” to check if it changed it as expected:

However, it might not work if your system has time synchronization enabled (NTP). You need to disable it first with:
sudo timedatectl set-ntp false
Once disabled, do the previous command again, and it should keep your entry as the current date/time.

NTP and Timedatectl configuration

By the way, NTP and Timedatectl are the tools you might need to understand if you want to go a bit further on this topic.
They are the reason why the time and date synchronization is working with an Internet connection, but not so well without it.

NTP is the protocol used for time synchronization on a network, and timedatectl is the tool installed by default on Raspberry Pi OS to manage it.
For example, even if your Raspberry Pi doesn’t have an Internet access, but can access a local network with a time server, you can edit the configuration to synchronize it with your own server instead of a “random” Internet server.

I will not go into details about this, but I have a dedicated guide about NTP that you should definitely read if you are interested.

This tutorial doesn't work anymore? Report the issue here, so that I can update it!

0 0 votes
Article Rating

Patrick Fromaget

I'm the lead author and owner of My goal is to help you with your Raspberry Pi problems using detailed guides and tutorials. In real life, I'm a Linux system administrator with a web developer experience.

Notify of
1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
Per-Olof Bergström
Per-Olof Bergström
1 year ago

Yey, finally some one that can explain how to manually set time in rpi in 2021.
It works!

Recent Posts

Master your Raspberry Pi - 10% off