I show that it's true in case $f$ is not only differentiable but also its derivative is continuous.
Since $f'$ is non-zero function, there is a point $\tilde{x} \in (a, b)$ such that $f'(\tilde{x}) > 0$ or $f'(\tilde{x}) < 0$. Suppose $f'(\tilde{x}) > 0$. Then take $c$ and $d$ as follows:
$$ \begin{align*}
c &:= \inf\{\, \tilde{c} \mid a \leq \tilde{c} \leq \tilde{x}, \quad f'(c') > 0 \quad \text{for all $c' \in (\tilde{c}, \tilde{x}]$} \,\} \\
d &:= \sup\{\, \tilde{d} \mid \tilde{x} \leq \tilde{d} \leq b, \quad f'(d') > 0 \quad \text{for all $d' \in [\tilde{x}, \tilde{d})$} \,\}. \\
\end{align*}$$
From assumption that $f'$ is continuous, $c \neq \tilde{x} \neq d$. The interval $(c, d)$ is the required one (indeed, the largest interval containing $\tilde{x}$).