We don’t know when the prophet Joel lived. It seems almost any date from 835 to 400 BC is possible, that is, as early as during the reign of Uzziah reign, or when Josiah was a child and had not yet taken the throne, or just before the fall of Jerusalem in 586 BC, and even as late as Israel’s post-exile restoration.
The various arguments are summarised here.
I’ve placed it just before the fall of Jerusalem in 586 BC because it seems to fit the overall narrative: Joel’s use of a severe drought and locust plague to demonstrate the effect of an invading army from the north (there were regional droughts around the time of the Babylonian invasion), and the language around the future burning of Jerusalem (which happened in 586 BC).
It could also have been written outside an extant timeframe. Much of the prophecy is interpreted as being about Jesus and the “end times”. Indeed, the army from the north could just as easily have been the Romans, or the Gog and Magog of Ezekiel 38 and 39.
The central message is isn’t affected:
Joel 2:12 That is why the Lord says,
‘Turn to me now, while there is time.
Give me your hearts.
Come with fasting, weeping, and mourning.
Don’t tear your clothing in your grief,
but tear your hearts instead.’
Return to the Lord your God,
for he is merciful and compassionate,
slow to get angry and filled with unfailing love.
He is eager to relent and not punish.
Who knows? Perhaps he will give you a reprieve,
sending you a blessing instead of this curse.
Perhaps you will be able to offer grain and wine
to the Lord your God as before.