Part of Rev.12 is past history, like verses 3-4 when Satan first rebelled and drew one third of the stars (angels) into rebellion with him. That was about his first casting out to the earth, a time when he setup that old beast system of ten horns, seven crowns, and seven heads. If you'll notice, the Rev.13:1 beast system has ten crowns instead of seven, pointing to a final beast system on the earth. But from Rev.12:6 to 12:17, it is pointing to the great tribulation timing.
Back at the end of Rev.8 through Rev.11:15, Christ gave us the order of the last three trumpets, because He linked them to 3 woe periods that follow in order. On the second woe, sixth trumpet, the locust army of Rev.9 is loosed upon the earth, and Rev.11 shows the 'beast' that ascends out of the bottomless pit is here on earth to kill God's two witnesses in Jerusalem. In Rev.9 on the sixth trumpet second woe, we're shown the locust army has a king over them which is the angel of the bottomless pit, i.e., Satan. Rev.12:7-9 shows Satan and his angels being cast down to this earth in person, so the sixth trumpet is when they come to earth.
On the fifth trumpet of Rev.9 is when a great sealing in the mind of God's servants takes place, and I believe we have been in that one for a while now, but nearing its end. That sealing by God is represented by many in today's times that never before had an urge to really seek God and get into His Word in-depth, being given that urge, and understanding to go along with it to keep from being deceived with what's coming on the earth. God's sealing of Rev.9 is the opposite of Satan's sealing with his mark in the mind of the deceived, and in their hand (doing its works). That's why the locusts are told they can only 'sting' those not sealed with God's seal. Their stinging is about deception.