Before I explain my question, let me state that I have not read the books. I have only seen the show.
So to the question, Tywin is appointed as Hand of the King after he won the Battle of the Blackwater Bay. I believe that is the first time Tywin meets Joffrey (in the show). But before the events of the Blackwater Bay, when Tywin was in battle with Robb Stark, he appoints Tyrion as Hand of the King in his stead. I know that it is just a temporary appointment. But in order to do that, doesn't Tywin need to be already appointed as Hand by the King by Joffrey? In the shows, after Robert is killed, Joffrey just proclaims himself as the King and that's all.
When did Joffrey name Tywin as Hand of the King before Stannis' attack on King's Landing?