cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Time stamp changes in spark sql

User16826994223
Honored Contributor III

Hi Team

Is there a way to change the current timestamp from the current time zone to a different time zone .

1 REPLY 1

Srikanth_Gupta_
Valued Contributor

import sqlContext.implicits._

import org.apache.spark.sql.functions._

inputDF.select(

   unix_timestamp($"unix_timestamp").alias("unix_timestamp"),

   from_utc_timestamp($"unix_timestamp".cast(DataTypes.TimestampType), "UTC").alias("UTC"),

   from_utc_timestamp($"unix_timestamp".cast(DataTypes.TimestampType), "America/Los_Angeles").alias("pst_timestamp")

  )

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.