title: How to retain the timestamp format when extracting from a dataframe into a string in PySpark
body: <p>I have the following dataframe in PySpark (Databricks). How can I extract the exact literal timestamp as displayed in the dataframe into a string?. At the moment, using the code below, I  get: <strong>&quot;2022-02-25 06:32:29&quot;</strong> instead of <strong>&quot;2022-02-25T06:32:29.000+0000&quot;</strong>. some conversion is happening that strips of the milliseonds part including the 'T'. I want to retain the literal string as it appears on the dataframe?</p>
  <p><strong>code</strong>:</p>
  <pre><code>table = [x[&quot;ts&quot;] for x in ts.rdd.collect()]
  for row in table:
      print(row)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/AXiNM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AXiNM.png" alt="Dataframe" /></a></p>