How many years ago was the first computer invented?
The first analog computer invented was the Antikythera Mechanism, about 2000 years ago. One sample was found in an ancient shipwreck about 1910. It was designed to calculate astronomical positions for navigation.
The first digital computer invented was the Analytical Engine, about 200 years ago. It was never built. It was entirely mechanical and intended to be powered by a steam engine. It was fully programable and general purpose with an architecture very much like modern electronic digital computers.
Humans have been communicating with each other in many different ways for several hundred thousand years. The first digital computer was invented in the 1830s by Charles Babbage but never built. The first electronic digital computers were invented in the 1930s and built in the 1940s. Electronic digital computers did not become a marketed product until the 1950s.