Blackburn Magistrates’ Court heard that when Steven Scanlan was told he was going to be searched, he volunteered that he had a knife in his bag.
Scanlan, 32, of Spring Bank Terrace, Blackburn, pleaded guilty to possessing a kitchen knife in a public place.
He was sentenced to four months in prison, suspended for 12 months, and ordered to pay £85 costs and £154 victim surcharge.
Glenn Anderton, prosecuting, said officers attended the Accrington McDonald’s in Hyndburn Road at 4.15am on April 7.
“The defendant was behaving erratically,” said Mr Anderton.
“He was dancing and shadow boxing in front of the police vehicle.”
Gareth Price, mitigating, said his client had been living in a house of multiple occupation in Accrington and had been attacked on five separate occasions.
“His mental health deteriorated as a result, and he ended up taking this knife out for defence purposes,” said Mr Price.
“He was admitted to Royal Blackburn Hospital mental health unit nine days after this incident, and he remains there as a voluntary patient.”