Many mainline Christian denominations require a bachelor's degree and a Master in Divinity degree. The BA takes about 4 years. The MDiv takes 2 or 3 years. Some denominations require that you also study Greek, Hebrew, or Latin. That may add an additional year or two. Some denominations offer a preaching license without any formal schooling. It is best to check with a minister in your own faith tradition to be clear and to get the correct information. In addition to the academic degrees, ordination requirements include an internship of a year or two, training and practice as a chaplain in a hospital setting for 3-12 months, completion of an extensive psychological examination, and passing examinations in theology, worship, and polity (governance).
If you're talking a masters of divinity, it will often take 3-5 years depending on the program you apply to and what pace you go at. Masters degrees usually give you more flexibility on timeline.
If you're wanting to do pastor work these days, an official degree is less and less required unless the denomination you're a part of have a preferred track for their pastors to come through.