常用时间操作函数汇总表格
注:用 [ ] 括起来的表示是可选参数。
另外,在遇到不知道如何使用的函数时,下面这个命令可以查看函数详细信息,extended关键字展示了函数的使用参考案例:
desc function extended from_unixtime;
演示几个案例
1、获取当前时间戳
select unix_timestamp();
--返回结果:1619404342
unix_timestamp(void)将被弃用,使用unix_timestamp(current_timestamp())替代
select unix_timestamp(current_timestamp());
--返回结果:1619404342
上面默认是获取的10位的秒级时间戳,获取13位的毫秒时间戳方式为:
select cast(cast(current_timestamp() as