“I only got four hours of sleep last night.”
A coworker mentions that you look sleepy. You explain why by saying this.
I only got four hours of sleep last night.
When you're talking about how much you slept at night, you usually use the expression "get ___ hours of sleep":
I usually get 7 or 8 hours of sleep every night.
You say "I slept for ___ hours" when you sleep for an extra long time, or when you fall asleep at a strange time of day:
I laid down after lunch and slept for 4 hours.