[subject] + [verb] + 了 + [duration] [subject] + [verb] + 了 + [duration] + (的) + [object] [subject] + [verb] + [object] + [verb] + 了 + [duration] [subject] + [duration] + 没 + [verb] + 了
A length of time goes after the verb. A time word that says when goes before it, so 我三点睡觉 is "I go to bed at three", and 我睡了三个小时 is "I slept for three hours".
The duration cannot follow the object. Either repeat the verb, or put the duration between the verb and the object, with or without 的.
A separable verb like 睡觉, 上课 or 开会 takes the duration inside it.
With 了 after the verb and another at the end, the stretch of time runs up to now and the action is still going on.
Here the time phrase moves in front of the verb, because there is no action to measure, and the negator is 没.
多长时间 and 多久 both ask how long. 几个小时 asks for a small number of hours.