note 14095 added to ref.datetime.php
| From: | shinelight at excite dot com | Date: | Tue, 17 Jul 2001 11:42:26 +0000 |
| Subject: | note 14095 added to ref.datetime.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15479@lists.php.net to get a copy of this message | ||
For those who want portable timestamps between ODBC-compliant datasources, use the following format:
{ts '1890-12-30 00:00:00'}
(The above timestamp is associated as the "zero-base" in many datasources)
So, to use the above timestamp in a query, do something like this:
INSERT INTO MyTable (Table_ID, Table_TS)
VALUES (1, {ts '1890-12-30 00:00:00'})
If you just want to use the date, use this:
{d '1890-12-30'}
Or just the time:
{t '00:00:00'}
That should ease someone's pain. Instead of running a query against the database for a
timestamp (which is generally slow), you can generate one real-time. For instance:
echo "{ts '".gmdate("Y-m-d h:i:s", time())."'}";
It is just a matter of modifying the above code for whatever queries you need to perform.
MacTruck
(BTW, if you can't tell, those are braces '{}' rather than parenthesis '()'
surrounding the timestamp...they are also known as "escape characters" in ODBC
terminology).
http://www.php.net/manual/en/ref.datetime.php