A man accused of threatening another person with a knife and causing them immediate risk of serious harm has changed his plea to guilty.