If do you need to know date and time in your Arduino project, so you need a Real-Time Clock (or RTC)!
One of the most famous RTC ICs is DS1307, from Dallas Semiconductor. DS1307 uses I²C (or Two-Wire Interface - TWI) to communicate with Arduino. This library is just a layer above Wire library to make RTC easy to use.
Download the tarball, uncompress it and put the directory DS1307
inside your personal library folder (~/sketchbook/libraries/
-- on GNU/Linux) or in the Arduino-system library folder (/usr/share/arduino/libraries
on GNU/Linux -- requires root access).
For now that are only 3 examples: SetDateHardcoded
, SedDateSerial
and ReadDate
-- the names autoexplain. :-) Install the library and go to File
-> Examples
-> DS1307
-> (choose one example).
There is a RTC module with DS1307 sold by SparkFun - this library was tested only with this module.
The code of this library is based on Wiring.org.co RTC example and Daniel Gonçalves post at LusoRobótica Forum - thanks, guys!