To express that an action was carried out over a certain length of time, English uses often "for". This is a very versatile word in English, so there a few different points to consider when expressing the same thing in Mandarin.
In most cases the length of time is added right after the verb. Simple as that. Some examples:
Jīdàn zhìshǎo yào zhǔ 5 fēnzhōng.
Eggs should be boiled for at least five minutes.
Wǒmen kěnéng qù lǚxíng jǐ tiān.
We could go travelling for a few days.
Nǐ zhǐhǎo yǐnfú jǐ gè xīngqí.
You'd better lie low for a few weeks.
Notice how in each of these examples it's almost like the verb includes the sense of "for" as it is. You don't need to add anything else in to mark the length of time. Just placing it after the verb expresses that the verb takes place for that length of time.
Including an object
The sentences above don't include an object. If there is one, the length of time goes after this. This is because the object is actually part of the verb phrase. So you're still just putting the length of time after the verb.
Nǐ kěyǐ bāng wǒ shí fēnzhōng ma?
Could you help me for ten minutes?
Tā kěyǐ jí wǒ de mótuō chē jǐ tiān.
He can borrow my moped for a few days.
Jǐngchá huì zhuībǔ tā hěn cháng shíjiān.
The police will pursue her for a long time.
If you group the object and verb into one chunk, the structure is just the same as the first set of example sentences.
Note that for separable verbs, the time can also be inserted in the middle of the verb. A couple of examples:
Tā měitiān shàng jǐ gè xiǎoshí wǎng.
She goes online for several hours every day.
Nǐ yīnggāi měi tiān shuì bā gè xiǎoshí jiào.
You should sleep for eight hours a day.
Length of time at the beginning
Sometimes it's better to put the length of time near the beginning of the sentence. This happens when a verb phrase is used as the subject of the sentence.
It sounds complicated but it just means that an action itself causes something to happen. An action is performing an action.
Děng tài cháng shíjiān ràng dà bùfèn de rén jué dé xīnfán.
Waiting for too long makes most people annoyed.
Yī zhěnggè yuè méi kàn dào tāmen ràng wǒ gǎnjué hěn nánguò.
Not seeing them for a whole month makes me sad.
Jiè jiǔ yī nián duì shēntǐ hǎo.
Giving up drinking for a year is healthy.
Notice how this is often handled with -ing verbs in English. If a sentence starts with an -ing verb in English, chances are the duration needs to go near the beginning when translating into Chinese.
What about 了?
You might have noticed that the example sentences above all talked about hypothetical or habitual actions. I did that on purpose to save all the 了goodness for this section!
The example sentences above don't need 了 as they don't specify whether or not the action is completed in the time frame we're talking about. If time frames are involved, you can be sure that the aspect particle 了 is going to rear its ugly head.
Simply put, 了 is used to mark actions that are complete in the time frame we're talking about. The above sentences don't need 了 as they talk about uncompleted actions. Now it's time to start looking at some time duration sentences that do need 了.
Putting 了 after a verb indicates that the action of that verb is completed in the time frame we're talking about. With duration, 了 indicates that the verb has been carried out for that length of time.
Wǒ zuótiān kànle liǎng gè xiǎoshí diànshì.
I watched TV for two hours yesterday.
Nǐ dàole yǐhòu děng yīhuǐr.
When you get there, wait for a while.
Wǒ xiūxíle yīhuǐ'er zài yào chūqù.
I'll go out after I've rested for a while.
Wǒ zuó wǎn shuìle bā gè xiǎoshí jiào.
I slept for eight hours last night.
In each of the examples above, the action of the verb is complete in the time frame being described. Notice how 了 can be used in sentences about the past, present and future. It's about completeness, not when something happens.
As well as the 了 that marks completeness, there is another kind of 了. This is often called sentence 了. Sentence 了 is used to indicate a new state or new situation.
When aspect 了 and sentence 了 are used together, it expresses the sense of "this is how things are up to now". In English this is often expressed with "have" plus the past tense form of the verb.
Combining both kinds of 了 with a duration expresses that an action has been performed for that length of time so far. It implies that the action is going to continue in duration.
Wǒmen yǐjīng děngle hǎojǐ gè xiǎoshí le.
We've been waiting for hours.
Wǒ rènshile tā yǒu shí nián le.
I've known him for ten years.
Tāmen kànle nà bù diànyǐng bàntiān le.
They've been watching that film for ages.
Negative sentences with duration and 了
After all that, it might seem strange to talk about negative 了 sentences. If 了marks completed actions, surely a negative (and so uncompleted) action wouldn't need 了?
That is true for aspect particle 了, but not for sentence 了. Sentence 了 can mark that something has not been the case for an amount of time. This is a bit like saying "it's now the case that [not x] for [amount of time]".
Wǒ hǎoduō tiān méi chī dōngxile.
I haven't eaten for days.
Tāmen yǐjīng sìshíbā gè xiǎoshí méi shuìjiàole.
They haven't slept for forty-eight hours.
Wǒmen yǐjīng shí duōnián méi kànguò tāle.
We haven't seen him for over ten years.