Shocked parents waiting to collect their children saw Barry Philips with a blade in his hand as he looked in a playroom window.
Police raced to the scene and Philips, of Glencairn Avenue, Craigneuk, was detained nearby.
The 43-year-old appeared at Hamilton Sheriff Court this week.
At an earlier hearing he admitted unlawful possession of a knife outside Craigneuk Family Learning Centre and Nursery in November 2019. An allegation that he acted in a threatening or abusive manner by striking windows with the knife was dropped.
Jennifer Cunningham, prosecuting, stated: "Two witnesses were waiting to collect their children. They saw the accused approach one of the nursery windows holding what looked like a knife in his hand."
Philips looked in the window before turning away towards the main road.
Police officers were given a description of the knifeman and detained Philips a short distance away. They found a butter knife in his pocket.
The fiscal added: "He was slurring his words and the officers took him to hospital for assessment before he was discharged into police custody."
Philips claimed he picked up the knife in the street near the nursery and had no intention of using it. Defence agent Tom Watters said his client has mental health issues. He had been abusing alcohol and drugs after he was the victim of a serious knife assault.
The solicitor added: "He had a young relative who attended the nursery so he looked in the window and then walked away In his garbled mind it was some kind of joke.It's highly unlikely that anyone would go out with a butter knife with the intention of using it as a weapon.
"That backs up my client's position that he found this item in the street only a short time before the incident."
Sheriff Linda Nicolson put Philips under social work supervision for a year.
She told him: "On the face of it, this is a serious matter and custody would be merited. However, given the background circumstances, I think it's open to the court to impose a community-based disposal."
A tagging order was also imposed on Philips confining him to his home between 7pm and 7am for six months.