How to connect them? Normally, RTC use an I2C connection. So, on the top of the Raspberry PinOut there is the I2C connection:
The RTC that was used to do this post use the last ten pinout pins (on picture: left area).
Once RTC is connected with the Raspberry, the next step is configuring the Rapsberry. First, the config.txt Linux file has to be modified.
Type on your Raspberry Terminal to open it:
sudo leafpad config.txt
Then, on config.txt must be uncommented the line #dtparam=i2c_arm=on (without the #) to enable the I2C connection and must be added the next line:
«ds1307» this is the RTC used on this example. There are many on the marked just use the name of your RTC (if there is identified for the Linux).
After that the Raspberry must be rebooted.
When the Raspbery is running again type the next command lines to set the date on your Raspberry:
sudo date -s 20170623120000
This command line corresponds to set the next date: 23/06/2017 12:00:00
After to set up the date on your RTC type on terminal:
sudo hwclock -w
This is all that you must do to configure the RTC on your Rapsberry pi. To be sure that your sets up succeed type:
The Terminal shall show you the configured date.