- skip to content

# Database Abstraction Layer

### User Tools

- Login

### Site Tools

- Recent changes
- Media Manager
- Sitemap

### Sidebar

##### Resources

- Reference Manual
- User Guide
- The Data Dictionary
- ADOdb-xmlschema
- ADOdb Active Record
- Performance Monitoring
- Date/Time Library
- Session Management Library
- Unsupported Addons
- Coding Standards

##### Supported Databases

- Access
- ADO
- CSV
- Firebird
- Frontbase
- IBM DB2
- Informix
- Interbase
- LDAP
- Microsoft SQL Server
- MySQL
- Netezza
- ODBC
- ODBTP
- Oracle
- PDO
- Postgresql
- SAP ADS
- SAP ASE
- SAP Maxdb
- SAP Sqlanywhere
- Sqlite
- Sybase
- Plain Text
- Visual Foxpro

##### Other

- Feature Comparison Matrix
- Connection Matrix
- Include File Guide

v5:reference:connection:bindtimestamp

# bindTimeStamp

##### syntax

    string bindTimeStamp(){
           mixed $timestamp
           }

## Description

The function `bindTimeStamp()` accepts a number of different types of parameters, and returns a database-specific dateTime string. This can then be used in bind statements. The returned value differs from one database to another.

### Parameters

#### PHP DateTime Option

    /*
     * Connection to Oracle database assumed
     */

    $dateTime=new DateTime("2012-07-08 11:14:15.638276");

    $d = $db->bindTimeStamp($dateTime);
    /*
     * Returns the following string: TO_DATE('2012-07-08 11:14:15','RRRR-MM-DD, HH24:MI:SS')
     */
    $SQL = "SELECT * FROM record WHERE date_time_field=$d";

#### Unix Timestamp Option

    /*
     * Connection to Oracle database assumed
     */

    $timestamp = date('Y-m-d');

    $d = $db->bindTimeStamp($timestamp);
    /*
     * Returns the following string: TO_DATE('2015-07-19 00:00:00','RRRR-MM-DD, HH24:MI:SS')
     */
    $SQL = "SELECT * FROM record WHERE date_time_field=$d";

#### ISO Date String Option

    /*
     * Connection to IBM DB2 database assumed
     */

    $timestampString = '2015-01-01 19:30:15';

    $d = $db->bindTimeStamp($timestampString);
    /*
     * Returns the following string: TO_DATE('2015-01-01 19:30:15','YYYY-MM-DD HH24:MI:SS')
     */
    $SQL = "SELECT * FROM record WHERE date_time_field=$d";

v5/reference/connection/bindtimestamp.txt · Last modified: 2016/01/16 18:12 by mnewnham

### Page Tools

- Show pagesource
- Old revisions
- Backlinks
- Rename Page
- Back to top