A teenage thug who tried to smash his way into a car with a large zombie knife walked free from court today on the condition he stays at home at night with his mother for the next nine months.

Joshua Gardner, 18, produced the fearsome weapon from his trousers when the car pulled out in front of him and almost knocked him from his bike.

In front of shocked passers-by in the busy Croydon street, Gardener tried to smash his way through the car window with the knife and repeatedly kicked the side of the vehicle.

Dash-cam footage from another car showed Gardner, then only 17-years-old, smashing the passenger-side window and reaching through with the weapon in his hand, forcing the driver to abandon his vehicle and flee.

Footage of the incident, which happened at 5pm on May 30, went viral online and Gardner admitted affray and possession of an offensive weapon. He denied but was convicted at trial last week of attempting to cause grievous bodily harm.

Judge Anuja Dhir QC told the teenager the “extremely serious” incident warranted a jail sentence, but she was setting him free because he has “a realistic prospect of rehabilitation”.

She handed Gardner a two-year prison sentence suspended for two years, a nine-month curfew between 7pm and 7am, and 150 hours of community service. He must also complete up to 20 days of rehabilitation and 19 “thinking skills” sessions.

“I can see your mother in the public gallery and she is aware I was considering these requirements and appreciates what it means”, said the judge.

“Given all that I have seen, heard and read about you, I think this sentence offers protection to the public and punishment by way of a curfew and the unpaid work, but also it provides you with an opportunity to address your offending behaviour.”

Judge Dhir said she had read a supportive letter from Gardner’s mother, as well as a probation report outlining his troubled upbringing including, at the age of 13, finding his brother dead from a seizure.

She was also told the teenager claims to have been the victim of a kidnapping at the end of March, where he was held in a “trap house” for ten days and forced to sell drugs.

The footage of the zombie knife attack was played to the Old Bailey last week during Gardner’s trial, which went ahead despite the victim refusing to cooperate with police.

“It was a frightening incident, you attacked a car in a threatening and menacing way”, said the judge.

“You were cycling at the time when the driver of a blue car, Mr Gilbert, pulled out and clipped your bike.

“It was clear you knew Mr Gilbert. You were then seen to attack the car with your foot, your fists, and with a zombie knife you produced from your waistband.

“You were seen to attack the driver’s window and side of the car. You then tried to open the back passenger door and moved swiftly to the other side of the car and smashed the front passenger window.

“You put your hand with the knife in it into the car, and Mr Gilbert got out of the car and ran away.”

The judge said Gardner had initially intended to hurt the driver, but evidently had abandoned that plan as he did not pursue him down the street.

Gardner, from Thornton Heath, who has a previous conviction for attempted robbery of a schoolboy while brandishing a pocket knife, has spent nearly six months in custody awaiting his trial, but walked free this afternoon following the sentencing hearing.

Michael Halepas, a senior prosecutor at the CPS, said the case was not hampered by the lack of cooperating witnesses as the dash cam footage was so clear.

“The violence that unfolded so suddenly in broad daylight on a busy Croydon street horrified members of the public. Joshua Gardner pulled a zombie knife out and used it to savagely smash the door of a vehicle in to get to the driver inside. Luckily for the driver who fled the scene, Gardner did not pursue him beyond the vehicle.

“The key evidence in this case was the dash-cam footage that captured the attack. Gardner denied that he intended to cause any harm, but using the strong video evidence supplied by a passing vehicle’s dash-cam, the prosecution was able to prove to jurors that he was lying. The jury was satisfied that Gardner had intended to use the zombie knife against the victim and not merely scare him.

“We recognise the scourge of serious knife crime on this city and are working hard to prosecute offenders.”