pyspark.sql.functions.timestamp_millis#
- pyspark.sql.functions.timestamp_millis(col)[source]#
Creates timestamp from the number of milliseconds since UTC epoch.
New in version 3.5.0.
Examples
>>> spark.conf.set("spark.sql.session.timeZone", "UTC") >>> time_df = spark.createDataFrame([(1230219000,)], ['unix_time']) >>> time_df.select(timestamp_millis(time_df.unix_time).alias('ts')).show() +-------------------+ | ts| +-------------------+ |1970-01-15 05:43:39| +-------------------+ >>> time_df.select(timestamp_millis('unix_time').alias('ts')).printSchema() root |-- ts: timestamp (nullable = true) >>> spark.conf.unset("spark.sql.session.timeZone")