Used to refer to a specific class period in a school timetable, often with a number (e.g., 1時間目, 2時間目).
First period is math.
The third period is math.
What's the next period?
We have P.E. during the fifth period.
Once second period ends, it's break time.
時間 means 'time' or 'an hour' in general, whereas 時間目 is only used to number a specific class period, as in 3時間目 (the 3rd period).
Compound of 時間 (time, hour) and 目 (ordinal suffix), literally 'the -th hour/period'.