Although How I Met Your Mother presented multiple timelines, thankfully, enough details were uncovered to ascertain every main HIMYM character's age — but how old are the characters in How I Met Your Mother? The sitcom heavily focused on Ted Mosby as he told his two children, Penny and Luke, the expansive tale about how he met their mother. This story was the driving force behind the entire series while Ted from 2030 narrated the show, which was initially set in modern-day 2005. It then followed big events surrounding Ted and his closest friends: Marshall, Lily, Barney, and Robin.
https://screenrant.com/how-met-mother-characters-ages-how-old-explained/