ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:sqldate

This is an old revision of the document!


sqlDate

Syntax
string sqlDate(
                string $dateFormat,
       optional string $dateColumn
       )

Description

When the function sqlDate() is passed a string formatted using PHP date formatting it returns a database-independent date string, either using the system date, or if passed a string containing a datetime column in a table, a string derived from that column.

Usage

/*
 * Assumes connection to oracle database
 */
$dateString  = $db->sqlDate('Y-m-d')
/*
 * Returns: TO_CHAR(SYSDATE,'YYYY-MM-DD');
 */
 
$dateString = $db->sqlDate('m/d/y','trousers.purchase_date');
/*
 * Returns: TO_CHAR(trousers.purchase_date,'MM/DD/YYYY')
 */
v5/reference/connection/sqldate.1452648688.txt.gz · Last modified: 2017/04/21 11:32 (external edit)