Uniform continuity of $\phi(x)=\phi(x+1)$

Let $$\phi:\mathbb{R}\to\mathbb{R}$$ be a continuous function with $$\phi(x)=\phi(x+1)\;\forall x\in\mathbb{R}$$. Prove that $$\phi$$ is uniformly continuous.

I'm struggling with finding $$\delta >0$$, such that $$|f(x)-f(y)|<\epsilon\;\forall x,y$$ with $$|x-y|<\delta$$, for a given $$\epsilon$$, which is basically the definition of uniform continuity.

• Hint: $\phi$ is a continuous and periodic function with period $1$, so it is enough to consider the interval $\left[0,1\right]$. What we know about continous functions on a compact set? – Marco Cantarini Jan 11 at 16:05
• @MarcoCantarini They are uniformly continuous. Thanks! – user Jan 11 at 16:13

Let $$\varepsilon>0$$. By Heine-Cantor, $$\left.\phi\right\rvert_{[0,2]}$$ is uniformly continuous, and therefore there is some $$\delta_\varepsilon<\frac12$$ such that, for all $$x,y\in[0,2]$$ such that $$\lvert x-y\rvert<\delta_\varepsilon$$, $$\lvert \phi(x)-\phi(y)\rvert<\varepsilon$$.
Now, consider $$x,y\in\Bbb R$$ such that $$\lvert x-y\rvert<\delta_\varepsilon$$. Since the two points are in the interval $$\left(x-\frac12,x+\frac12\right)$$, there is an integer $$n_{x,y}$$ such that $$x-n_{x,y}, y-n_{x,y}\in [0,2]$$. Namely, a choice such as $$n_{x,y}=\begin{cases} \lfloor x\rfloor&\text{if }x-\lfloor x\rfloor \ge\frac12\\ \lfloor x\rfloor-1&\text{if }x-\lfloor x\rfloor <\frac12\end{cases}$$ works.
Now, $$x-n_{x,y}$$ and $$y-n_{x,y}$$ are in $$[0,2]$$ and $$\lvert (x-n_{x,y})-(y-n_{x,y})\rvert=\lvert x-y\rvert<\delta_\varepsilon$$. Therefore $$\lvert \phi(x-n_{x,y})-\phi(y-n_{x,y})\rvert<\varepsilon$$. By hypothesis, $$\phi(t+n_{x,y})=\phi(t)$$ for all $$t$$, thus proving that $$\lvert \phi(x)-\phi(y)\rvert<\varepsilon$$.