On the ABC comedy, “Haley [Phil & Claire’s daughter] is my daughter,” he tells The Post. “Alex is my other daughter [Alexandra].”

Levitan says he stopped short of naming 13-year-old Luke (played by Nolan Gould) after his son Griffin because “I thought Luke was going to be dumber than he turned out to be, and I didn’t want to put that on my son.

“Griffin’s best friend was named Luke,” Levitan says. “So we named the character after him instead.”

And Lily Aldrin (Alyson Hannigan) on “How I Met Your Mother” got her name from astronaut Buzz Aldrin.

Others, like Brad Williams (Daymond Wayans Jr.) and Max (Adam Pally) on “Happy Endings” are named after long-time friends of the show creators.

“[The real] Max is my friend since preschool,” creator David Caspe says. “He has a very similar personality to Max the character — but he is not gay.”

Character names, no matter how clever, have to be cleared by network execs before making it to air.

“The rule of thumb — especially if you identify the area where they are from — is that it has to be a name that nobody has or that everybody has,” says Jonathan Groff, executive producer of ”Happy Endings.”

“When I name characters, I spend hours and hours. I have the same fascination with things like names and name origins that Sheldon [the obsessive lead character in “Big Bang”] does.”

Here are some of the other stores behind the names:

* TRACY JORDAN (“30 Rock”): “Tracy Morgan claims to this day that his original name was something like ‘Bo-Bo,’” producer Robert Carlock says. “He said to Tina: ‘When people see me in the airport, I can’t have them saying ‘Hey Bo-Bo!’’ So she said, ‘How about ‘Hey Tracy?’

“It was really just to avoid him getting called Bo-Bo in public.”

* LIZ LEMON (“30 Rock”): “In this world where a lot of people get called by their last names, you just want a fun last name,” Carlock says. “And Tina [real name: Elizabeth] liked Lemon because it sounds fun, but it also connotes a certain sourness.

“She figured that was sort of perfect for the character. It encapsulates her character and the character’s character. Bright and sour.”

* PENNY (“Big Bang Theory”): “Sheldon and Leonard first met her on the street,” Prady says. “She was the ‘lucky penny’ that you pick up.”

In the original pilot — which featured a different actress — the name was changed to Katie because there was another show on CBS with a character named Penny.

It was later changed back.

* TED MOSBY (“How I Met Your Mother”): “When Carter Bays and I lived in New York, our band, The Solids made a little album,” co-creator Craig Thomas says. “There was a bar called Fez on the Upper West Side. Whenever we’d come in, the DJ there, Josh Mosby. switched to a song from our album. This was as close as we’ve ever come to rock stardom, so we felt the need to honor Josh Mosby.”

* BARNEY STINSON & ROBIN SCHERBATSKY (“How I Met Your Mother”): “The last name “Scherbatsky” is from a character in the novel Anna Karenina,” Thomas says. “The last name Stinson is a tribute to the band the Replacements (Carter and I are both big fans). Their bass player is Tommy Stinson.”