Utility function to convert datetimes into ISO8601 format