unix_millis
Returns the number of milliseconds since 1970-01-01 00:00:00 UTC. Truncates higher levels of precision.
For the corresponding Databricks SQL function, see unix_millis function.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.unix_millis(col=<col>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| input column of values to convert. |
Returns
pyspark.sql.Column: the number of milliseconds since 1970-01-01 00:00:00 UTC.
Examples
Python
spark.conf.set("spark.sql.session.timeZone", "America/Los_Angeles")
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([('2015-07-22 10:00:00',), ('2022-10-09 11:12:13',)], ['ts'])
df.select('*', dbf.unix_millis(dbf.to_timestamp('ts'))).show()
spark.conf.unset("spark.sql.session.timeZone")