for PADI, the Rescue Course should take about 4 days including the EFR. DM can take 2 weeks or 2 years depending on where you go and how you approach the course. If you do an internship then about 4-6 months would be a good stretch.
DM will depend on how many dives you have (60 required prior to certification), your fitness levels (if you can't swim you're not going to be able to to the 400 metres duing a 2 week course) and how brainy you are. If you're a bit shy of physics and biology then you'll need study time. Also, if you're working in the evenings and weekends for a shop in the UK then it would probably take longer than if you were at a full time CDC or working in a resort. I know one guy in Thailand who gives free DM courses to Thai divers for no charge - but they have to sign up to a 2 year unpaid working internship....
I personally completed a ivemaster internship that took me 5 months to complete. I could have done it quicker but I wasn't in a rush and was rather enjoying myself, to be honest! Later, as an instructor, I developed a program at my school that could be completed within two weeks, although we preferred our candidates to spread those two weeks over several months to get an 'internship' experience in between.
Hope that helps,
C.