相关疑难解决方法(0)

如何将时间戳转换为字符串(不更改时区)?

我有一些unix时间,我转换为时间戳sparklyr,由于某些原因我还需要将它们转换为字符串.

不幸的是,似乎在转换为字符串时hive转换为EST(我的语言环境).

df_new <- spark_read_parquet(sc, "/mypath/parquet_*",
                             overwrite = TRUE,
                             name = "df_new",
                             memory = FALSE,
                             options = list(mergeSchema = "true"))
> df_new %>%  
           mutate(unix_t = from_utc_timestamp(timestamp(t) ,'UTC'),
           date_str = date_format(unix_t, 'yyyy-MM-dd HH:mm:ss z'),
           date_alt = to_date(from_utc_timestamp(timestamp(t) ,'UTC'))) %>% 
    select(t, unix_t, date_str, date_alt) %>% head(5)
# Source:   lazy query [?? x 4]
# Database: spark_connection
            t unix_t              date_str                date_alt  
        <dbl> <dttm>              <chr>                   <date>    
1 1419547405. 2014-12-25 22:43:25 2014-12-25 17:43:25 EST 2014-12-25
2 1418469714. 2014-12-13 11:21:54 2014-12-13 06:21:54 …
Run Code Online (Sandbox Code Playgroud)

timestamp hive r apache-spark sparklyr

3
推荐指数
1
解决办法
501
查看次数

标签 统计

apache-spark ×1

hive ×1

r ×1

sparklyr ×1

timestamp ×1