title: PySpark Milliseconds of TimeStamp
body: <p>I am trying to get the difference between two timestamp columns but the milliseconds is gone.</p>
  
  <p>How to correct this?</p>
  
  <pre><code>from pyspark.sql.functions import unix_timestamp
  timeFmt = "yyyy-MM-dd' 'HH:mm:ss.SSS"
  
  data = [
      (1, '2018-07-25 17:15:06.39','2018-07-25 17:15:06.377'),
      (2,'2018-07-25 11:12:49.317','2018-07-25 11:12:48.883')
  
  ]
  
  df = spark.createDataFrame(data, ['ID', 'max_ts','min_ts']).withColumn('diff',F.unix_timestamp('max_ts', format=timeFmt) - F.unix_timestamp('min_ts', format=timeFmt))
  df.show(truncate = False)
  </code></pre>