The earliest recorded use of a trumpet that is currently known for music is in the late 14th to early 15th centuries - late 1300s to early 1400s. However, trumpets themselves date back to ancient Egypt, with the earliest recorded use of a trumpet ever being in around 1500 BCE.
However, trumpets back then were usually used like we use a bugle today: to signal in the military or in religious ceremonies. This is because they were incredibly simple to make, and some were even simply hallowed out rams’ horns.
As the trumpet design improved in the medieval period, so did the sound it made and the range of sounds it could make. This is when the trumpet began to be part of orchestras, bands, etc.