Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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
from pyspark.databricks.sql import functions as dbf
dbf.unix_millis(col=<col>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or str |
input column of values to convert. |
Returns
pyspark.sql.Column: the number of milliseconds since 1970-01-01 00:00:00 UTC.
Examples
spark.conf.set("spark.sql.session.timeZone", "America/Los_Angeles")
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")