fixed time and date formatting, and placed it in a function.