Have a look at the code in Several Things at a Time. It should not be too difficult to adapt it for what you want.
I presume it won't matter if the Arduino does not measure an hour accurately. If it does you will need a Real Time Clock (RTC) module.
...R