The Mesozoic Era was the geological era in which dinosaurs lived, as well as the first mammals. It lasted about 186 million years, starting 252.2 mya (million years ago) with the P/Tr extinction and ending 65 mya with the K/T extinction (the one that killed all dinosaurs except birds).
Dinosaurs appeared around 231 mya (21 million years after the beginning of the Mesozoic). They evolved from the reptiles called archosaurs. Modern birds and crocodiles are part of that group.