Low-dimensional dynamics for working memory and time encoding