How long do the two witnesses prophesy?
The two witnesses prophesy for one thousand two hundred and threescore days, which is three and a half years.
Scripture tells us plainly how long the two witnesses will minister. Revelation 11:3 says, "And I will give power unto my two witnesses, and they shall prophesy a thousand two hundred and threescore days, clothed in sackcloth." That number of days works out to three and a half years, the very same length of time the Antichrist will bring desolation and abominations upon the nation of Israel.
During this three and a half year period, the two witnesses stand as the two olive trees and the two candlesticks before the God of the earth, given power to shut heaven so it does not rain, to turn waters to blood, and to smite the earth with plagues whenever they choose, much like Elijah and Moses did in their own days. Once they finish their testimony at the end of those 1,260 days, the beast that comes up out of the bottomless pit makes war against them, overcomes them, and kills them in the city of Jerusalem, where their bodies lie in the street for three and a half days before God raises them and calls them up to heaven in a cloud.
The Body of Christ is still on the earth during this entire span of the witnesses' ministry, which underscores just how significant this three and a half year window is in the unfolding of end time events.
The scriptures
And I will give power unto my two witnesses, and they shall prophesy a thousand two hundred and threescore days, clothed in sackcloth. These are the two olive trees, and the two candlesticks standing before the God of the earth. And if any man will hurt them, fire proceedeth out of their mouth, and devoureth their enemies: and if any man will hurt them, he must in this manner be killed. These have power to shut heaven, that it rain not in the days of their prophecy: and have power over waters to turn them to blood, and to smite the earth with all plagues, as often as they will. And when they shall have finished their testimony, the beast that ascendeth out of the bottomless pit shall make war against them, and shall overcome them, and kill them. And their dead bodies shall lie in the street of the great city, which spiritually is called Sodom and Egypt, where also our Lord was crucified. And they of the people and kindreds and tongues and nations shall see their dead bodies three days and an half, and shall not suffer their dead bodies to be put in graves. And they that dwell upon the earth shall rejoice over them, and make merry, and shall send gifts one to another; because these two prophets tormented them that dwelt on the earth. And after three days and an half the Spirit of life from God entered into them, and they stood upon their feet; and great fear fell upon them which saw them. And they heard a great voice from heaven saying unto them, Come up hither. And they ascended up to heaven in a cloud; and their enemies beheld them. And the same hour was there a great earthquake, and the tenth part of the city fell, and in the earthquake were slain of men seven thousand: and the remnant were affrighted, and gave glory to the God of heaven. The second woe is past; and, behold, the third woe cometh quickly.
From the books
This answer is drawn from these passages in the Mary Banks Faith Library.