It depends on who you work for, how many hours you fly, and what type of flying you do.
Being very general here, it could take between 2 and 4 years to gain the 1500 hours to obtain the ATPL. This doesn't automatically make you a Captain. These positions go to the more senior pilots, seniority being the yardstick in many airlines. You also have to show an ability to command an aircraft, not just fly it. Bear in mind that if you move jobs you will end up at the bottom of the seniority ladder again regardless of your previous experience.
Current timescales are around 8 to 10 years to command but the industry is changing all the time. This could increase/decrease at any time.
This is as I understand it but stand to be corrected by those pruners with more experience than me.