Former U.S. Rep. Anthony Weiner was ordered Friday by a judge to register as a sex offender, according to The Associated Press.

>> Read more trending news

Weiner, a Democrat who served from New York, is nearing the end of a 21-month prison sentence for having illicit online contact with a 15-year-old girl. A New York City judge labeled Weiner as a Level 1 sex offender, which means he is a low risk to be a repeat offender, the AP reported.

Weiner must register for a minimum of 20 years.

Weiner did not attend Friday's court hearing in Manhattan, as he is residing in a halfway house. He is due to be released May 14, according to the AP.