How should I install a digital timer?
Presumably the black and red wires are the hot and switched, corresponding to your current switch. If the box is gounded, that one's good. The issue (depending how the box is wired) may be that the timer needs a neutral connection, and if the box only has "switch loops" run to it it may not currently HAVE a neutral wire - in which case you need to get one there.

Now, when you say that there are 5 cables in the box, do you mean 5 multi-wire cables (black-white-bare/green) except one of them is red-black-white-bare/green and there are a lot of white wires connected to each other? If so, it's your lucky day, as one of those white wires will provide your neutral connection. Avoid white wires that are connected to switches, as those probably are NOT neutrals.

A picture would help a lot, but that's my educated guess, if you are using "cable" in the usual sense, as opposed to confusing it with "wire."