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.

If you need help getting started on Raspberry Pi, I have an entire course to guide you through your first steps. I’ll help you use the perfect hardware, plug everything in and install your first system. You’ll also do your first project with me, just to make sure you are ready for the next level. Get all the information on this page if you are interested.

Best Free Desktop Clock Widgets for...
Best Free Desktop Clock Widgets for Windows 11 and 10

Why are date and time an issue on Raspberry Pi?

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.

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.

Download the Pi Glossary!
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!
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 Raspberry Pi OS 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.

Note: If you really need a hardware clock, there is a way to add a module (like this one on Amazon) via the GPIO pins. I won’t explain this in details here, but that’s something to think about for projects where time is important but where the Raspberry Pi is not connected to the Internet.

Set Date and Time on Raspberry Pi OS with Desktop

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.

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.

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

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”
  • 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.

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.

Are you a bit lost in the Linux command line? Check this article first, for the most important commands to remember, and a free downloadable cheat sheet so you can have the commands at your fingertips.

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 more details about this, but I have a dedicated guide about NTP that you should definitely read if you are interested.

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

Reminder: Remember that all the members of my community get access to this website without ads, exclusive courses and much more. You can become part of this community for as little as $5 per month & get all the benefits immediately.


If you want to see those tips in action, you can watch this video on my YouTube channel:

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

Additional Resources

Not sure where to start?
Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Watch the Raspberry Pi Bootcamp course now.

Master your Raspberry Pi in 30 days
Don’t want the basic stuff only? If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.
Download the e-book.

VIP Community
If you just want to hang out with me and other Raspberry Pi fans, you can also join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
More details here.

Need help building something with Python?
Create, understand and improve any Python script for your Raspberry Pi.
Learn the essentials, step-by-step, without losing time understanding useless concepts.
Get the e-book now.

You can also find all my recommendations for tools and hardware on this page.

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.

Recent Posts