Postgres: How do I format an int timestamp as readable date string?

后端 未结 1 1960
执念已碎
执念已碎 2021-02-05 13:57

Say I have a column that contains unix timestamps - an int representing the number of seconds since the epoch. They look like this: 1347085827. How do I format this

1条回答
  •  梦毁少年i
    2021-02-05 14:51

    Postgresql has a handy built-in function for this: to_timestamp(). Just wrap that function around the column you want:

    Select a, b, to_timestamp(date_int) FROM t_tablename
    

    0 讨论(0)
提交回复
热议问题