Police were called to a Tesco Extra in Mansfield after members of the public saw a knife strapped to a bike that was left outside.
Adam Petrica was arrested when he returned to the bike, chained up outside the Chesterfield Road South store, at 12.40pm on June 26.
He told police he realised he still had the black handled work knife on him, and then strapped it to his bike and forgot all about it, said prosecutor Emma Heath-Tilford.
Chris Perry, mitigating, said Petrica, of previous good character, and took full responsibility.
He said it was "a far cry from gang-related violence and terrorism", but having it on his person outside of work "becomes automatically illegal without good reason."
He said Petrica is an honest man "who works seven days a week for very little to send money home to his wife and two children."
Petrica, 33, of Recreation Street, Mansfield, admitted the offence via a Romanian interpreter, when he appeared at Mansfield Magistrates Court, on Friday.
Magistrates sentenced him to 28 days in prison, suspended for 12 months. He was ordered to pay £85 costs and a £115 government surcharge.
For more of the latest court cases click here.