returns the date according to a pattern