Format time correctly