< TIMESTAMP: Setting Query Format   (Previous) Table of Contents (Next)   TIMESTAMP: Literal Data Type >

TIMESTAMP: Formatting Query

/**
 * Returns the query string fragment needed for the current DBMS to
 * produce an ISO formatted timestamp from a timestamp column
 *
 * @param   string   $col  the database column to get the data from
 * @return  string   the query fragment your DBMS needs
 */
function formatTimestampQuery($col) {
    return sprintf($this->TimestampQueryFormat, $col);
}

require 'connect.inc';

$query = 'SELECT ' . $p->formatTimestampQuery('tf') . ' FROM t';
echo "$query\n";
$out = $db->getOne($query);
echo $out;
mssql
SELECT CONVERT(CHAR(19), tf, 120) FROM t
2002-03-04 10:20:30
pgsql
SELECT tf FROM t
2002-03-04 10:20:30