timezone - Spark: converting GMT time stamps to Eastern taking daylight savings into account -
i'm trying convert column of gmt timestamp strings column of timestamps in eastern timezone. want take daylight savings account.
my column of timestamp strings this:
'2017-02-01t10:15:21+00:00' i figured out how convert string column timestamp in est:
from pyspark.sql import functions f df2 = df1.withcolumn('datetimegmt', df1.mytimecolumningmt.cast('timestamp')) df3 = df2.withcolumn('datetimeest', f.from_utc_timestamp(df2.datetimegmt, "est")) but times don't change daylight savings. there function or accounts daylight savings converting timestamps?
edit: think figured out. in from_utc_timestamp call above, needed use "america/new_york" instead of "est":
df3 = df2.withcolumn('datetimeet', f.from_utc_timestamp(df2.datetimegmt, "america/new_york"))
i ended figuring out answer, figured add here. think question/answer worthwhile because while searching issue before posting question, couldn't find daylight savings spark. should have realized should search underlying java functions.
the answer question ended being use string "america/new_york" instead of "est". correctly applies daylight savings.
from pyspark.sql import functions f df3 = df2.withcolumn('datetimeet', f.from_utc_timestamp(df2.datetimegmt, "america/new_york"))
Comments
Post a Comment