ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:dbdate

This is an old revision of the document!


dbDate

<WRAP right box>

syntax
string dbDate(){
       float $timestamp
       }
       

<WRAP>

Description

The function dbDate() accepts a Unix Timestamp value, and returns a database-specific date string. This can then be used in SQL statements. The returned value differs from one database to another.

Usage

MySQL example

/*
 * Connection to MySQL database assumed
 */
$date = date('Y-m-d');
 
$d = $db->dbDate($date);
/*
 * Returns the following string: '2015-07-19'
 */
 
$SQL = "SELECT * FROM record WHERE date_field=$d";

Oracle Example

/*
 * Connection to Oracle database assumed
 */
$date = date('Y-m-d');
 
$d = $db->dbDate($date);
/*
 * Returns the following string: TO_DATE('2015-07-19','YYYY-MM-DD')
 */
 
$SQL = "SELECT * FROM record WHERE date_field=$d";
v5/reference/connection/dbdate.1437321639.txt.gz · Last modified: 2017/04/21 11:35 (external edit)