For most people, the Raspberry Pi operating system (whichever one you use) will do this in the background, and this shouldn’t be a problem.
But in some cases, for example B. if you start with your Pi Framboise or if you use it without an internet connection, this can be a problem.
In this article we see how we can solve a date and time problem on your Pi Framboise.
By default, NTP is enabled on the Raspberry Pi operating system and connects to a web server to set the date and time.
It can also be adjusted manually, via the desktop interface or with the sudo date -s command ‘YYYYY-MM-DD HH:MM:SS’.
I will now give you the details and suggest a solution that should help you in most cases, whether you use a work environment or not and whether your Pi is connected to the internet or not.
Why is the date and time on the Pi of the raspberry a question?
With a computer, you rarely think about setting the date and time correctly.
You can adjust it after installation and you will probably forget about it for years.
However, with the Raspberry Pi, the problem can occur regularly, especially if you use it without Internet access or if you are not using the latest version of the Raspberry Pi operating system.
The first reason is that the Raspberry Pi OS depends on an internet connection to get and keep the right date and time.
In the desktop version it is not possible to set the date and time directly in the interface, the only thing you can change is the time zone.
But the other reason has to do with the hardware.
Each computer has a battery that makes it possible to store the date and time, even if it is disconnected from the power source for a long period of time. There’s no such thing as raspberry pis. alt=width=700 height=337 data-ezsrc=http://server.digimetriq.com/wp-content/uploads/2021/01/How-to-Set-the-Date-and-Time-on-Raspberry-Pi.jpg data-ez= />Lithium battery on the computer’s motherboard
In more recent versions of Pi OS Raspberry (since Stretch, I think), there is a package that solves this problem: a fake clock. It stores the current date and time in the operating system’s files so that they can be restored after a restart if there is no Internet connection.
If you are using an older raspbian system or another operating system, you may need to consider something before proceeding, as I will not describe this case below.
Set the date and time on Raspberry Pi OS with desktop
If you use the Raspberry Pis OS, setting the date and time should be quite easy if you have access to the internet.
But let’s see what you can do to install it properly.
When you start your Pi OS Raspberry for the first time, a configuration wizard will appear asking you for some information.
One of them is your location.
Your P asks the question not only out of curiosity, but also determines the time zone based on your answer. alt= width=507 height=336 data-ezsrc=http://server.digimetriq.com/wp-content/uploads/2021/01/1610182869_678_How-to-Set-the-Date-and-Time-on-Raspberry-Pi.jpg data-ez= />
After setting the time zone, the operating system synchronizes the date and time of the system with the Internet server and displays the correct clock based on your location.
In most cases, you’re done after that. The Raspberry Pi synchronizes regularly with the time provider, and that should be good.
Course Raspberry Pi
Go to the next step.
I’m here to help you get started with your Raspberry piss and learn all the necessary skills in the right order.
Raspberry PiConfiguration tool
If you missed the welcome wizard or if you 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 Settings > Raspberry Settings.
In the Location tab you can change the current time zone: alt= width=593 height=452 data-ezsrc=http://server.digimetriq.com/wp-content/uploads/2021/01/1610182870_244_How-to-Set-the-Date-and-Time-on-Raspberry-Pi.jpg data-ez= />
Select the one that matches your location and press OK twice to save the changes.
After a few seconds the time in the upper right corner needs to be updated.
On a Raspberry Pi operating system with a desktop computer this is the only control you have directly in the interface.
You can set a different time zone, but you cannot set the date and time manually.
To do this, you must use the command line.
If these tips didn’t work for you, read on for more solutions.
Before you continue, if you are a little lost on the Raspberry Pi OS desktop and need help, I have a solution for you. The My Raspberry Pi Bootcamp course takes you through the first steps, from understanding the hardware to setting up your first operating system to replace your desktop. I will also guide you in the creation of your first 5 raspberry piping projects.
More information can be found on this page.
Set the date and time on command line.
If you use Raspberry Pi OS Lite or are connected via SSH, you will not have access to these tools. Don’t worry, there are similar command line alternatives.
The easiest way to correct your time zone is to use a short grater setting to quickly get comparable results.
Raspi-config is the main configuration tool available on Raspberry Pi OS Lite that allows you to configure many settings, including date and time:
- Run the tool with this command:
sudo raspi configuration
- Go to the location options and then to time zone
alt=raspi config width=700 height=271 data-ezsrc=http://server.digimetriq.com/wp-content/uploads/2021/01/1610182870_339_How-to-Set-the-Date-and-Time-on-Raspberry-Pi.jpg data-ez= />.
- Select a specific geographical area and time zone.
The system configuration is then updated with the new date/time.
By the way, you can display the current date and time with this command:
So with Raspi configuration we can do the same as in the desktop interface, but we still can’t configure the date and time manually.
The only way to set a custom date is to use the command line.
Here is a command to set the date and time manually:
sudo date -s ‘DATE’
sudo date -s ‘2021-01-04 13:04:00′
The date is not required, it can also be used:
sudo date -s ’13:04:00’
Works in the same way.
The date command supports most date formats, but if in doubt, check the GNU website for more information.
Use the date command to see if it has changed as expected:
date alt= width=642 height=130 data-ezsrc=http://server.digimetriq.com/wp-content/uploads/2021/01/1610182871_350_How-to-Set-the-Date-and-Time-on-Raspberry-Pi.jpg data-ez= />
However, this may not work if time synchronization (NTP) is enabled on your system. You must disable it first:
sudo timedatectl set-ntp false
After disabling, repeat the previous command and it should save your entry as the current date/time.
NTP and TimedatectlConfiguration
By the way, NTP and Timedatectl are tools you need if you want to go deeper into this topic.
That’s why the time and date synchronization works with an internet connection, but not so well without it.
NTP is the protocol used to synchronize time on the network, and timedatectl is the default tool installed on the Raspberry Pi operating system to manage it.
Even if you’re Raspberry Pi z. B. does not have access to the Internet, but does have access to the local network with a time server, you can change the configuration to synchronize with your own server instead of any Internet server.
I won’t go into detail, but I have a specific guide for the NTP that you should definitely read if you are interested.
raspberry pi get current time command,raspberry pi sudo date,raspberry pi wrong time,raspbian date command,change raspberry pi clock to 12 hour,raspberry pi time not updating,raspberry pi date wrong,raspbian buster change time,sudo date –set,fix clock raspberry pi,raspberry pi set time without internet,raspbian reset time,raspberry pi 3 b+ update time,raspberry pi digital clock settings,check time on raspberry pi,libreelec set time manually,raspberry pi set timezone script,fix raspbian clock,raspberry pi 4 time,raspberry pi ntp synchronized: no,raspberry pi get current time python,sudo date -s,raspberry pi set time command line,raspberry pi set time manually,raspberry pi set time and date without internet,raspberry pi set clock on boot,sudo date -s raspberry pi,raspberry pi set time source