Joshua Packer-Ender, 18, repeatedly punched the victim before waving a knife in his face during the incident in Horsforth, Leeds.
Leeds Crown Court heard the attack happened outside the victim’s house around 9.15am on January 20 this year.
Martin Robertshaw, prosecuting, said the victim and his pregnant wife were about to get into their car to go to hospital so she could have her 12-week scan.
The husband then noticed Packer-Ender “loitering” outside his home and challenged him about what he was doing.
Mr Robertshaw said: “The defendant approached the complainant. Entirely unprovoked, he started punching the complainant to the side of the head.”
The victim fell to the ground during the the attack and Packer-Ender tried to kick him.
Packer-Ender then walked away but became angry when the victim began to take pictures of him on his mobile phone.
He returned moments later, bare-chested and waving a knife.
The victim’s wife described being petrified and thought her partner was about to be stabbed.
Police were called and Packer-Ender was arrested nearby.
The court heard the victim was left with loose teeth and a cut lip from the attack. He also suffered bruising to his thumb.
Packer-Ender, of Belle Isle Close, Belle Isle, Leeds, pleaded guilty to assault and making threats with an offensive weapon.
Sajid Majid, mitigating, said: “The circumstances speak for themselves and there is nothing I can say to make the circumstances seem any better than they were. It was an appalling offence.”
Mr Majid said his client had been suffering from mental health issues at the time and had pleaded guilty to the offences at an early stage.
Packer-Ender was sentenced to five months in a young offenders’ institution.
Recorder Nicholas Barker said: “They should have taking what was a very happy and memorable trip to the hospital to have a scan of their forthcoming child.
“These are very troubling offences indeed. On that morning you were wholly unpredictable, violent and deeply threatening.”