note 22532 deleted from function.time by aidan
| From: | aidan@php.net | Date: | Sat, 08 Oct 2005 01:07:36 +0000 |
| Subject: | note 22532 deleted from function.time by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96643@lists.php.net to get a copy of this message | ||
Note Submitter: merrick at condesamarketing dot com
----
*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