Bethlehem is the city of birth of king David.  Upon the basis of a remarkable astronomic conjunction of planets the appealing legend of the star of Bethlehem was constructed.  Jesus was born in Bethlehem on August 21, 7 BC, at noon. 
True, Joseph did go to the City of David, Bethlehem, to be registered for the Roman census, but that was because, six generations previously, Joseph’s paternal ancestor of that generation, being an orphan, was adopted by one Zadoc, who was a direct descendant of David; hence was Joseph also accounted as of the “house of David.  Herod killed sixteen baby boys at Bethlehem in his attempt to kill the infant Jesus.  Mary had never fully given up the idea that Jesus ought to grow up in Bethlehem, the City of David. 
The people living in Galilee did not know that Jesus had been born in Bethlehem. They always supposed the Master had been born at Nazareth, as did the vast majority of his disciples, but the twelve knew the facts.