Who wrote the Epic of Gilgamesh and when was it written?
We don't know who wrote it, but it is believed to have been written around... 3000bc
The person credited with writing Gilgamesh is Shin-eqi-unninni somewhere between 2500-2000bc
Gilgamesh, was perhaps adopted, because he came under the lineage of his Uncle Cush and, at the age of fourteen, he began to be called Nimrod. Asshur and Nimrod conquered Assyria during the fifty years following the birth of Arphaxad (2665 BC).
The earliest fragments of Sumerian Gilgamesh poems date to around 2000BCE. These were individual poems, parts of which were later incorporated into the full epic. The earliest evidence we have for the combined epic dates to around 1800BCE - the "Old Babylonian" version. This version was edited and expanded by Sin-lequi-unninni in the middle Babylonian period (probably somewhere between 1300 - 1000BCE) to produce the so called "standard version" of the epic. It is commonly held that the full flood narrative was added to the story at this time, almost certainly based on the flood story from the Epic of Atrahasis (c1700BCE).
Apart from the middle Babylonian editor we have no idea who composed the original Sumerian poems or the Old Babylonian epic. It was evidently written in poetic form and designed to be sung as court entertainment.