Giving a child a spanking is not illegal. But battery of a child is quite another matter, typically leaving painful pronounced bruising that inspired a child's school to notify the police of the batterer's actions.
From what you say, you stood in open court and, under oath, confessed to the court that you battered the child. To put it mildly, it's tough to go back to court after being sentenced and convince a judge, "When I confessed under oath, I was lying to you, so you should set aside my conviction and let me have a trial."

