====== bindTimeStamp ======
~~NOTOC~~
== 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";