Format date function.