Spark SQL - Get Current Timezone

event 2022-06-16 visibility 4,931 comment 0 insights
more_vert
insights Stats
Kontext Kontext Code Snippets & Tips

Code snippets and tips for various programming languages/frameworks. All code examples are under MIT or Apache 2.0 license unless specified otherwise. 

Spark SQL adds a new function named current_timezone since version 3.1.0 to return the current session local timezone.  Timezone can be used to convert UTC timestamp to a timestamp in a specific time zone. 

Code snippet

spark-sql> SELECT current_timezone();
Australia/Sydney

Time zone can be used with other Spark functions like from_utc_timestamp which converts a UTC timestamp to a particular timestamp in a specified time zone.

spark-sql> SELECT from_utc_timestamp('2022-06-16', current_timezone());
2022-06-16 10:00:00
More from Kontext
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts