The first writing we can call writing is from around 3,500 BC, but this is just the oldest surviving evidence — the true origin of writing must be much, much older.
Irving Finkel introduces the origins of writing in Mesopotamia around 3,500 BC, explains how pictographic signs evolved into phonetic syllabic writing, and argues that the oldest surviving evidence is unlikely to be anywhere near the true moment of invention.
transcript
Irving Finkel: The first attempts at writing that we could call writing go back to the middle of the 4th millennium, say, around 3,500 BC, something like that. There were people in the Middle East, individuals who lived between the Euphrates and Tigris rivers, who had clay as their operating material for building and all sorts of other purposes, and eventually as a writing support, they somehow developed the idea of the basis of writing, which means that you can make a sign, which people agree on, a surface, that another person, when they see it, they know what sound it engenders. That is the essence of writing, that there's an agreed system of symbols, that A can use and B can then play back, either in their heads or literally with their voices, a bit like a gramophone record. So when it really began, it's a terribly, terribly awkward question for us, because the truth of the matter is we have no idea when anything began. And all we can say is that the oldest evidence we have is around 3,500 BC. But whether that was anywhere near the time or the stage when this started off for the first time seems to me very, very unlikely.