tronixstuff have written a great tutorial how to interface and program real time clocks (RTC). As an example he took two widely used chips DS1307 and DS3231. The main difference between both modules is clocking mechanism that can result in precision. Usually they come in modules that can be easily connected to microcontroller board via I2C interface.
Both modules come with built in pull-up resistor, so there are only two wires required to interface to microcontroller (plus power lines). Simple demo program allows to output time and date infromation to serial terminal window every seconds. Both modules come with backup batteries so if you diconnect them from Arduino board they will continue counting time. When next time you connect them again, you will get correct time values.