note 22532 added to function.time
| From: | merrick at condesamarketing dot com | Date: | Fri, 21 Jun 2002 02:53:13 +0000 |
| Subject: | note 22532 added to function.time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32082@lists.php.net to get a copy of this message | ||
*PostgreSQL timestamp note
As mentioned above PostgreSQL does not have a timestamp, you must extract the epoch from the
timestamp you stored in your database which is in PostgreSQL Timestamp format.
Getting the PostgreSQL Timestamp into your database from a form can be accomplished with a hidden
form object having the value attribute set to "now()"
----------------------------------------
e.g.
<input type='hidden' name='pgsql_timestamp' value='now()'>
----------------------------------------
Now if you need to get the Unix timestamp from the PostgreSQL timestamp which is stored like
"2002-06-19 16:51:09.83662-07"
you can do the following SQL query
----------------------------------------
e.g.
"SELECT EXTRACT(EPOCH FROM pgsql_timestamp) AS unix_timestamp FROM my_pgsql_table;"
now unix_timestamp = "1024815600"
----------------------------------------
If not clear, "pgsql_timestamp" would be the name of the column which holds the PostgreSQL
timestamp, it would be returned as "unix_timestamp" and would be the Unix Timestamp.
*Note your table still has the timestamp in PostgreSQL format
--
http://www.php.net/manual/en/function.time.php
http://master.php.net/manage/user-notes.php?action=edit+22532
http://master.php.net/manage/user-notes.php?action=delete+22532
http://master.php.net/manage/user-notes.php?action=reject+22532