Code of Alabama
Article 1 - General Provisions.
Section 15-18-5 - Credit Towards Sentence for Time Spent Incarcerated - Pending Trial.

(a) Upon conviction and imprisonment for any felony or misdemeanor, the sentencing court shall order that the convicted person be credited with all of his or her actual time spent incarcerated pending trial for the offense. The actual time spent incarcerated pending trial shall be certified by the circuit clerk or district clerk on forms to be prescribed by the Department of Corrections.
(b) Upon a child being adjudicated delinquent and committed to the Alabama Department of Youth Services in a juvenile court for a felony or a misdemeanor for a set period of time or as a serious juvenile offender as specified in subsection (a) of Section 12-15-219, the juvenile court shall order that the delinquent child be credited with all of his or her actual time spent detained prior to or subsequent to adjudication for the offense. The actual time spent detained shall be certified by a juvenile probation officer on forms to be prescribed by the Department of Youth Services.