Re: php, time and postgresql
От | Tom Lane |
---|---|
Тема | Re: php, time and postgresql |
Дата | |
Msg-id | 21717.979337291@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | php, time and postgresql (Rasmus Resen Amossen <spunk@rhk.dk>) |
Список | pgsql-general |
Rasmus Resen Amossen <spunk@rhk.dk> writes: > I want to save some time information in postgresql with php. What is the > datatype in postgresql coresponding to the mktime()-unixtime function in > php (creates a time in the format "979333398" eg.)? You can coerce an integer representing a Unix timestamp to abstime, and thence to any other datetime datatype you might want to use. play=> select now()::abstime::integer; ?column? ----------- 979337141 (1 row) play=> select 979337141::integer::abstime; ?column? ------------------------ 2001-01-12 17:05:41-05 (1 row) The "official" way to get from a datetime type to a Unix timestamp is date_part('epoch', timevalue): play=> select date_part('epoch', now()); date_part ----------- 979337212 (1 row) but I don't know of any easy way to go in the other direction except by casting to abstime. regards, tom lane
В списке pgsql-general по дате отправления: