Here is a time library on the playground. I have not used this but it may be what you are looking for.
http://playground.arduino.cc/Code/Time