Updated datetime formatting logic in main script.