According to one of my professors, the statement "For each language L that is accepted by a DTM in polynomial time, there is also a DTM M′ that decides L in polynomial time." is true, but i do not understand why, as the statement "For each language L that is accepted by a DTM, there is also a DTM M′ that decides L." is obviously false (e.g. the halting problem).
My first intuition was, that you could measure the runtime of a DTM and see if it accepts an input in polynomial time and if it does not, reject the input. The issue is, that i dont know how i would decide if a DTM spend more than a "polynomial" amount of time on an input.
Your first intuition is basically correct; you just need one extra insight. If $\ L\ $ is accepted by a DTM, $\ T_L\ $, say, in polynomial time, then there exists a polynomial $\ p_L\ $, which can be assumed to have integer coefficients, such that any word of $\ L\ $ of length $\ \ell\ $ will be accepted by $\ T_L\ $ in $\ p_L(\ell)\ $ steps or fewer. Let $\ M'\ $ be a DTM which does the following:
Such a machine will decide $\ L\ $ in polynomial time.
The thing here is that you don't need to know what $\ p_L\ $ is to establish the existence of $\ M'\ $. You only need to know that it exists, and it must exist if $\ L\ $ is accepted in polynomial time by $\ T_L\ $.