There was a cartoon about some kids who found dinosaur fossils and made them into pets that could fight other dinosaurs. It also had time travel involved. I think it was a mid 2000s show.
(It looks like someone beat me to the punch with this answer while I was writing it! Sorry about that, I'll leave mine here for extra information!) There are a lot of dinosaur cartoons, but from your description you may be referring to the cartoon Dinosaur King which aired between 2007 to 2008, and focused on a trio of kids who each had their own pet dinosaur and called themselves the "D-Team." Each dinosaur had its own elemental attack, and could be summoned from and stored within a card using a special stone. The kids frequently faced off against a group of stranded time-traveling scientists. The D-Team try to protect their new dino friends from the scientists, and so it becomes a battle for who can collect the dinosaur cards first.
This also has some episodes on Youtube, including the first:
There are (not too surprisingly) a fair number of cartoon shows involving battling dinosaurs. The one that I immediately thought of that involved the good guys having dinosaur pets and using them to fight against the villains' dinos was Dino-Riders. It first ran in 1988, and there was only one season, but it seemed to pop up in reruns a fair amount for many years afterwards.
According to Wikipedia:
The series focuses on the battle between the heroic Valorians and the evil Rulon Alliance on prehistoric Earth. The Valorians were a superhuman race, while the Rulons comprised several breeds of humanoids (ants, crocodiles, snakes, and sharks were the most common). Both races came from the future but were transported back in time to the age of dinosaurs. Once on Earth, the Valorians befriended dinosaurs, while the Rulons brainwashed them.
The pilot episode is on YouTube: