字符串和时间

一、unix_timestamp 函数用法
1、unix_timestamp() 返回当前时间戳。另外,current_timestamp() 也有同样作用。

select unix_timestamp()  #输出:1530230400

2、unix_timestamp(string date) 返回 date 对应的时间戳,date 格式必须为 yyyy-MM-dd HH:mm:ss。

select unix_timestamp('2018-06-29 00:00:00');


3、unix_timestamp(string date, string format) 返回 date 对应的时间戳,date 格式由 format 指定。

 select unix_timestamp('2018/06/29 09', 'yyyy/MM/dd HH');

二、from_unixtime 函数用法

1、from_unixtime(int/bigint timestamp) 返回 timestamp 时间戳对应的日期,格式为 yyyy-MM-dd HH:mm:ss。

 select from_unixtime(1000000000);  //输出:2001-09-09 09:46:40

 

2、from_unixtime(int/bigint timestamp, string format) 返回 timestamp 时间戳对应的日期,格式由 format 指定。

select from_unixtime(1000000000, 'yyyy/MM/dd HH');

原文链接:https://blog.csdn.net/HappyRocking/java/article/details/80854778

posted @ 2020-07-16 16:46  muyue123  阅读(126)  评论(0编辑  收藏  举报