(1)获取当前时间
在Mysql中获取当前时间,可以直接使用now()函数,输出为yyyy-MM-dd HH:mm:ss格式日期,如下:
eg:select now()
>2020-09-02 14:19:49
在Hive中输出当前日期函数为current_date()函数,如下:
eg:select current_date()
>2020-09-02
在Hive中还可以通过current_timestamp()函数输出时间,如下:
eg:select current_timestamp()
>2020-09-02 14:23:39.473
在Hive中还有各unix_timestamp()函数,输出当前时间戳,如下:
eg:select unix_timestamp()
>1599027536
ps:可以使用from_unixtime()函数将时间戳转换为日期时间格式,完整格式为:yyyy-MM-dd HH:mm:ss,如下:
eg:select from_unixtime(unix_timestamp