天天看点

SQL:postgresql中生成当前时间以及当前时间戳

生成当前时间​​select now()​​

SQL:postgresql中生成当前时间以及当前时间戳

只保留到秒数​​select now()::timestamp(0)without time zone​​

SQL:postgresql中生成当前时间以及当前时间戳

生成当前时间戳​​SELECT EXTRACT(epoch FROM now())​​

SQL:postgresql中生成当前时间以及当前时间戳

生成当前时间戳(保留到秒数)​​SELECT EXTRACT(epoch FROM now()::timestamp(0))​​

SQL:postgresql中生成当前时间以及当前时间戳

时间戳转时间​​SELECT TO_TIMESTAMP((SELECT EXTRACT(epoch FROM now()::timestamp(0))))​​

SQL:postgresql中生成当前时间以及当前时间戳

时间戳转时间(保留到秒数)​​SELECT TO_TIMESTAMP((SELECT EXTRACT(epoch FROM now()::timestamp(0))))::timestamp(0)​​

SQL:postgresql中生成当前时间以及当前时间戳

字符串类型时间转时间戳​​SELECT to_timestamp ( '2020-03-21 18:13:59', 'yyyy-MM-dd hh24:mi:ss' )​​

without time zone作用是不带时区