We consider the Skorokhod problem in a time-varying interval. We prove existence and uniqueness for the solution. We also express the solution in terms of an explicit formula. Moving boundaries may generate singularities when they touch. We establish two sets of sufficient conditions on the moving boundaries that guarantee that the variation of the local time of the associated reflected Brownian motion is, respectively, finite and infinite. We also apply these results to study the semimartingale property of a class of two-dimensional reflected Brownian motions.