Yes, done here all the time. However buy quality products, as most people have had the "cheapy 3 for £10" packs of timers fail.
I have been through so many timers in my fish keeping career with common failures being
- Just die no display, nothing.
- Forget all their setting after a power cut.
- Randomly resetting to 00:00:00, especially if switching inductive loads eg air pumps.
- No longer switch on (or off) despite what the display indicates.
- Worse one was, timer locking up with output on and overdosing fertiliser into my tank !!!.
Best one I have is one of these, many many years old, never failed. But would have cost a fortune to the 7 switched outputs I required. Now relegated to Xmas light.
https://www.tlc-direct.co.uk/Products/SMETU17.html
I then moved to wireless controls.
https://www.ukaps.org/forum/threads/anyone-used-byron-home-easy-remote-timeswitches.21210/
Very convenient, get loads under your fish tank, but wireless is not 100% reliable, as I found out.
https://www.ukaps.org/forum/threads/smart-home-kit.48733/#post-479475
There are also quite a few "internet connected" sockets (£40 a go) that have timer functionality.
I now have this...
https://www.ukaps.org/forum/threads/how-to-use-a-plc-to-control-your-fish-tank.42993/
100% switching reliability, not missed a time period in last 6050 hours (250 days).