To talk about activities (= how you spend your time), use:
“for” + length of time
I lived in Amsterdam for five years.
“until” or “till” + end point
I’ll be working until six this evening. the verb “spend” + length of time + verb + “-ing”
He spent six years working as a waiter.
He spends all his time photographing insects.
To talk about achievements (= things you want to do or achieve), use:
“in” + length of time
Wait for me. I’ll be ready in about 10 minutes.
“by” + end point
Dinner is at eight, so we need to get there by 7.30. the verb “take” + length of time + “to” + infinitive
It takes a long time to learn a new language.